sql-bricks-postgres icon indicating copy to clipboard operation
sql-bricks-postgres copied to clipboard

fix converts.Array

Open cybermerlin opened this issue 7 years ago • 6 comments

for https://github.com/CSNW/sql-bricks/issues/98

cybermerlin avatar Nov 18 '17 22:11 cybermerlin

There should be a better solution. This breaks for non int, non text arrays. Also, what's your use case? Why can't you type cast in SQL?

Suor avatar Nov 23 '17 09:11 Suor

I can't use type cast in SQL because inline SQL used as a template for many types (in JavaScript understand Number or String, as BIGINT or TEXT). For other types may manually formatting SQL-string.

cybermerlin avatar Nov 28 '17 13:11 cybermerlin

You can do the same you do now only in your own code. Your code very specific anyway:

  • only text and integers are supported,
  • why text and bigint and not, varchar and int or even float?

This is unmergable.

Suor avatar Nov 28 '17 13:11 Suor

float = Number in js

cybermerlin avatar Dec 03 '17 00:12 cybermerlin

as you wish. I use from my repo

cybermerlin avatar Dec 03 '17 00:12 cybermerlin

Possible solution is to use sql.Array() wrapper and specify type there:

sql.update('category', {tags: sql.Array(tags, 'text')}).where(...)

Suor avatar Feb 23 '18 03:02 Suor