crysalead-js / sql-dialect

SQL Builder
MIT License
6 stars 2 forks source link

Invalid operators (not) exists #11

Closed esatterwhite closed 4 years ago

esatterwhite commented 4 years ago

The default operators have exists + not exists as list.

':exists'      : { builder: 'list' },
':not exists'  : { builder: 'list' },

I'm fairly certain exists takes a sub query in all cases

SELECT *
FROM table_a
WHERE table_a.column = X
AND EXISTS (
  SELECT 1
  FROM table_b where table_b.a = table_a.id
)

Even setting them to an empty builder / undefined builder causes the to render incorrectly

':exists' :  { },
':not exists'  :  undefined,

I have to delete them from the default operators, and express the key in my query as :exists() for it to work correctly.

The operator selection logic doesn't let me fully override them, I should be able to specify null or undefined and get the default behavior. But It doesn't seem like I can do that.

jails commented 4 years ago

They need to be removed from default operators ?

esatterwhite commented 4 years ago

Yes, I believe so. I'm not sure if that breaks anything else though.

I had to copy them out of the package, and manually remove them.

jails commented 4 years ago

Willing to create the PR ?