Skip to content

Commit

Permalink
improving _TN function
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed May 25, 2024
1 parent 057b09b commit 22abf90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/helpers/table-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ npm.utils.addInspection(TableName, function () {
*
* @returns {Table}
*/
function _TN(s) {
const [schema, table] = (s.raw ? s[0] : s).split('.');
function _TN(a, ...args) {
if (Array.isArray(a) && a.raw) {
a = args.length ? args.map((b, i) => a[i] + b).join('') : a[0];
}
const [schema, table] = a.split('.');
return table === undefined ? {table: schema} : {schema, table};
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-promise",
"version": "11.7.1",
"version": "11.7.2",
"description": "PostgreSQL interface for Node.js",
"main": "lib/index.js",
"typings": "typescript/pg-promise.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion typescript/pg-promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ declare namespace pgPromise {
ColumnSet: typeof ColumnSet
TableName: typeof TableName

_TN: (data: TemplateStringsArray | string) => ITable
_TN: (data: TemplateStringsArray | string, ...args: Array<any>) => ITable
}

interface IGenericPromise {
Expand Down

0 comments on commit 22abf90

Please sign in to comment.