You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using a sub select that has more than 1 filter in the where clause throws a binding error (too many arguments) when using .get().
Strangely the to_sql() does not throw this error (when using the same query) and returns a properly built query that is testable in db clients
To Reproduce
test_table=SomeModel.get_table_name()
date_today=date_utc.add(days=1).to_date_string()
date_7_days_ago=date_utc.subtract(days=6).to_date_string()
stats_builder= (
QueryBuilder()
.from_(test_table)
.where("user_id", current_user.id)
.count("id as all_time_count")
.avg("rating as all_timerating_avg")
.max("rating as all_time_rating_max")
.add_select(
"count_days_7",
lambdaquery: (
query.count("id as lc".format(test_table))
.from_(test_table)
.where("user_id", current_user.id)
# adding 1 or more of the following results in a binding error# Yes I know they are the same but this is just an example ;)
.between('updated_at', date_7_days_ago, date_today)
.where("updated_at", ">=", date_7_days_ago)
.where("updated_at", "<=", date_today)
# Where_raw DOES NOT throw the binding error presumably because # the values are inserted into the string and not being quoted as per bindings are
.where_raw(
"updated_at BETWEEN '{}' AND '{}'".format(
date_7_days_ago, date_today
)
)
),
)
# this workslogging.info(stats_builder.to_sql())
# this throws a binding error stats_result=stats_builder.get()[0]
Expected behavior
Sub selects with multiple where filters should work as expected
Desktop (please complete the following information):
OS: Mac OSX
Version 10.15.7
What database are you using?
Type: Postgres
Version 10.7
Masonite ORM v1.0.55
The text was updated successfully, but these errors were encountered:
Describe the bug
Using a sub select that has more than 1 filter in the where clause throws a binding error (too many arguments) when using .get().
Strangely the to_sql() does not throw this error (when using the same query) and returns a properly built query that is testable in db clients
To Reproduce
Expected behavior
Sub selects with multiple where filters should work as expected
Desktop (please complete the following information):
What database are you using?
The text was updated successfully, but these errors were encountered: