Skip to content

Commit

Permalink
Use the latest version of @mojojs/sql
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 9, 2022
1 parent 488d688 commit 0ff550b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"dependencies": {
"@mojojs/path": "^1.5.1",
"@mojojs/sql": "^1.0.0",
"@mojojs/sql": "^1.2.0",
"@mojojs/util": "^1.3.0",
"pg": "^8.7.0",
"stack-utils": "^2.0.5"
Expand Down
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import EventEmitter from 'events';
import {escapeIdentifier, escapeLiteral} from './util.js';
import {escapeIdentifier, escapeLiteral} from '@mojojs/sql';
import {Statement} from '@mojojs/sql';

export class Base extends EventEmitter {
Expand Down
29 changes: 0 additions & 29 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,6 @@ import type {QueryConfig} from 'pg';
import Path from '@mojojs/path';
import StackUtils from 'stack-utils';

/**
* Escape PostgreSQL identifier.
*/
export function escapeIdentifier(identifier: string): string {
return '"' + identifier.replaceAll('"', '""') + '"';
}

/**
* Escape PostgreSQL literal.
*/
export function escapeLiteral(literal: string): string {
let result = '';
let escapeString = false;

for (let i = 0; i < literal.length; i++) {
const char = literal[i];
if (char === "'") {
result += "''";
} else if (char === '\\') {
result += '\\\\';
escapeString = true;
} else {
result += char;
}
}

return escapeString === true ? ` E'${result}'` : `'${result}'`;
}

export function throwWithContext(error: any, query: QueryConfig): never {
if (error.position !== undefined) {
const pos = parseInt(error.position);
Expand Down
25 changes: 0 additions & 25 deletions test/util.js

This file was deleted.

0 comments on commit 0ff550b

Please sign in to comment.