Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions __tests__/nusql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,48 @@ describe('nusql Data types', function () {
expect(nusql.build()).toBe('GTSVECTOR');
});
});
describe('SQL Date Handling Functions', () => {
var nusql;

beforeEach(function () {
nusql = index_1.default.create();
});

it('should generate a DATE data type', () => {
nusql.date();
expect(nusql.build()).toBe('DATE');
});

it('should generate a DATETIME data type with fractional seconds precision', () => {
nusql.datetime(3);
expect(nusql.build()).toBe('DATETIME(3)');
});

it('should generate a TIMESTAMP data type with fractional seconds precision', () => {
nusql.timestamp(6);
expect(nusql.build()).toBe('TIMESTAMP(6)');
});

it('should generate a TIME data type with fractional seconds precision', () => {
nusql.time(2);
expect(nusql.build()).toBe('TIME(2)');
});

it('should generate a YEAR data type', () => {
nusql.year();
expect(nusql.build()).toBe('YEAR');
});

it('should generate a TIMESTAMP data type without fractional seconds precision', () => {
nusql.timestamp();
expect(nusql.build()).toBe('TIMESTAMP');
});

it('should generate a TIME data type without fractional seconds precision', () => {
nusql.time();
expect(nusql.build()).toBe('TIME');
});
});

describe('nusql Operators', () => {
var nusql;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nusql",
"version": "1.0.5",
"description": "Simplified SQL Query Builder for Node.js",
"main": "lib/index.js",
"main": "src/index.js",
"scripts": {
"test": "jest",
"build": "npx tsc",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class Nusql {
this.query += 'YEAR ';
return this;
}


/**
* Specifies the VARBINARY data type with the given size.
* @param {number} size - The size of the VARBINARY column.
Expand Down