@imatic/pgqb
Advanced tools
Comparing version 0.1.29 to 0.1.30
@@ -87,2 +87,5 @@ "use strict"; | ||
function columnList(columns) { | ||
if (columns.length === 0) { | ||
return ''; | ||
} | ||
return wrapInParens(columns.map((v) => escape(v)).join(', ')); | ||
@@ -312,3 +315,3 @@ } | ||
columns: (columns) => columnList(columns), | ||
values: (list) => appendToStatement(sql_template_strings_1.SQL `VALUES `, intersperse(', ', list.map((row) => valueList(row)))), | ||
values: (list) => list.length === 0 ? 'DEFAULT VALUES' : appendToStatement(sql_template_strings_1.SQL `VALUES `, intersperse(', ', list.map((row) => valueList(row)))), | ||
on_conflict: (columns) => `ON CONFLICT ${columnList(columns)}`, | ||
@@ -315,0 +318,0 @@ do_update: exprsHandler('DO UPDATE SET '), |
{ | ||
"name": "@imatic/pgqb", | ||
"version": "0.1.29", | ||
"version": "0.1.30", | ||
"description": "Functional PostgreSQL query builder", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -191,2 +191,6 @@ import {SQL, SQLStatement} from 'sql-template-strings'; | ||
function columnList(columns: string[]): string { | ||
if (columns.length === 0) { | ||
return ''; | ||
} | ||
return wrapInParens(columns.map((v) => escape(v)).join(', ')); | ||
@@ -517,3 +521,3 @@ } | ||
values: (list: Value[][]) => | ||
appendToStatement( | ||
list.length === 0 ? 'DEFAULT VALUES' : appendToStatement( | ||
SQL`VALUES `, | ||
@@ -520,0 +524,0 @@ intersperse( |
@@ -8,2 +8,15 @@ import {expect} from 'chai'; | ||
{ | ||
name: 'insert default values', | ||
actual: h.merge( | ||
h.insertInto('table_name'), | ||
h.columns([]), | ||
h.values([]) | ||
), | ||
expected: { | ||
insert_into: 'table_name', | ||
columns: [], | ||
values: [] | ||
}, | ||
}, | ||
{ | ||
name: 'insert_into', | ||
@@ -10,0 +23,0 @@ actual: h.merge( |
@@ -17,2 +17,14 @@ import {expect} from 'chai'; | ||
{ | ||
name: 'insert default values', | ||
map: { | ||
insert_into: 'table_name', | ||
columns: [], | ||
values: [] | ||
}, | ||
sql: { | ||
text: 'INSERT INTO "table_name" DEFAULT VALUES', | ||
values: [] | ||
} | ||
}, | ||
{ | ||
name: 'insert_into', | ||
@@ -19,0 +31,0 @@ map: { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99216
2290