deepstream.io-storage-postgres icon indicating copy to clipboard operation
deepstream.io-storage-postgres copied to clipboard

Maybe escape single quote in VALUES?

Open hdtp opened this issue 9 years ago • 1 comments

Have we considered to escape single quote in VALUES into double single quotes? Ex: Changing valueStrings.push(('${key}','${JSON.stringify( writeBuffer[ key ] )}')) into valueStrings.push(('${key}','${JSON.stringify( writeBuffer[ key ] )}.replace(/'/g, "''")'))

hdtp avatar Mar 20 '17 15:03 hdtp

Using Deepstream 3.0 from Docker Hub. The following record update causes an error when a single quote is used in data:

record = client.record.getRecord("bob")
record.set({name: "Bob's Burger", address: "123 Main Street"})

This is the error in the DS console:

RECORD_UPDATE_ERROR | { error: syntax error at or near "s"
    at Connection.parseE (/var/lib/deepstream/deepstream.io-storage-postgres/node_modules/pg/lib/connection.js:554:11)
    at Connection.parseMessage (/var/lib/deepstream/deepstream.io-storage-postgres/node_modules/pg/lib/connection.js:381:17)
    at Socket.<anonymous> (/var/lib/deepstream/deepstream.io-storage-postgres/node_modules/pg/lib/connection.js:117:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:547:20)
  name: 'error',
  length: 90,
  severity: 'ERROR',
  code: '42601',
  detail: undefined,
  hint: undefined,
  position: '92',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'scan.l',
  line: '1086',
  routine: 'scanner_yyerror' }

seamusv avatar Aug 04 '17 16:08 seamusv