spiral-modules / database

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
MIT License
53 stars 19 forks source link

`where between` with reverted order escapes the value as it is a column name #42

Closed vvval closed 4 years ago

vvval commented 4 years ago

Between query supports reverted order where args are not values but fields:

$source->where(
    123,
    'BETWEEN',
    'created', 'updated'
);

The output is equals to:

SELECT * FROM table_name WHERE "123" BETWEEN 'created' AND 'updated'

expected:

SELECT * FROM table_name WHERE 123 BETWEEN 'created' AND 'updated'
vvval commented 4 years ago

Update: I have to pass int value here as a string, because Quoter::quote() method requires a string as an input. Can the quoter be modified to ignore bool/numbers/null values while quoting expressions?

wolfy-j commented 4 years ago

Use new Parameter() instead of scalar value for the first argument and Expression for values.

vvval commented 4 years ago

Thanks