You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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:
Creating a 1-line defaultValues() method that sets this._default_values = true
Modifying the columns clause so it returns an empty string if this._default_values || !this._values
Modifying the values clause so it returns "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 ()
The text was updated successfully, but these errors were encountered: