Open coderuid opened 8 years ago
@coderuid: Sure enough, DEFAULT VALUES
is included in Sql-92, I had no idea. From section 13.8 <insert statement>
(page 388 of the spec):
<insert statement> ::=
INSERT INTO <table name>
<insert columns and source>
<insert columns and source> ::=
[ <left paren> <insert column list> <right paren> ]
<query expression>
| DEFAULT VALUES
<insert column list> ::= <column name list>
I'm ok with making it the default behavior if no values are provided, but I think it's important for it to also be available as explicit method like this: sql.insert('TableName').defaultValues()
-> INSERT INTO "TableName" DEFAULT VALUES
.
@coderuid: Are you interested in trying your hand at implementing this? The methods for the insert statement on are on lines 306-361 and the clauses for the insert statement are defined on lines 363-376. I think all that is necessary is:
defaultValues()
method that sets this._default_values = true
this._default_values || !this._values
"DEFAULT VALUES"
if this._default_values || !this._values
If you want to go above and beyond, you could add the new method to the documentation (index.html) and add a test (an example in the documentation, which will be converted into a test when you run tests/gen-tests.js
and/or an explicit unit test in tests/tests.js
).
With undefined values or columns in sql.insert() expected to use database defaults. Now we have
INSERT INTO "TableName" () VALUES ()