jawj / zapatos

Zero-abstraction Postgres for TypeScript: a non-ORM database library
https://jawj.github.io/zapatos/
Other
1.3k stars 46 forks source link

Using `all` type in Whereables gives error `Type 'unique symbol' has no properties in common with type 'Whereable'.` #171

Open yasithA opened 6 months ago

yasithA commented 6 months ago

Hello,

First of all, props for the awesome work you're doing with the library!

I have a question related to how the all type can be used in Whereables.

The scenario is that I build the whereable object conditionally and one condition allows it to have no where statement and retrieve the complete dataset. I'm aware that I can use {} instead of all in these situations, but I like using all given it's more expressive.

When the generated type looks something like this, with id as a number,

id?: number | db.Parameter<number> | db.SQLFragment | db.ParentColumn | db.SQLFragment<any, number | db.Parameter<number> | db.SQLFragment | db.ParentColumn>;

The following code works without errors:

let tableWhereable: table_name.Whereable = all;

But, when the id becomes a string, it starts complaining with the following error Type 'unique symbol' has no properties in common with type 'Whereable'.

I'm struggling to understand the difference of behaviour just because the id column's type is changed from number to string. I'm not sure if this is a bug or I'm missing something, so any help would be really appreciated.

Thank you!