Open aelttil opened 2 months ago
Thanks for the report!
I had a look yesterday and I did reproduce it. I initially thought it had to do with GraphQL, because I know GQL cannot contains colons in some stuff.
But it's not, it's because of ActiveRecord variable replacement in SQL. When we prepare the query, variables like :to_datetime
, :from_datetime
, :initial_value
are replace by their value.
ActiveRecord will look to replace :test
in WHERE billable_metrics.code = "test:test"
🤨
I'm not sure how to fix that. An easy way would be to disallow the :
char in the billable metric code but I'd rather fix it as the ActiveRecord model so it doesn't happen with other variable that are not supposed to be interpolated.
The fix requires us to update Rails to 7.1 (https://github.com/rails/rails/blob/main/activerecord/lib/active_record/sanitization.rb#L219)
To do so we need to upgrade clickhouse-activerecord
gem (Rebasing https://github.com/PNixx/clickhouse-activerecord into https://github.com/getlago/clickhouse-activerecord)
We are taking it into account in our roadmap @aelttil and we will let you know when it will be fixed.
In the meantime, the workaround is to avoid using :
in a billable metric code
The billable metric code appears not to support the ":" separator, despite its acceptance by the user interface. The issue does not occur with any Aggregation type. For instance, it works fine with the count type.
Steps to reproduce the behavior:
test:test
Error in UI![Screenshot 2024-04-29 at 10 40 19](https://github.com/getlago/lago/assets/10155402/39fc8cec-0ae7-43de-b2d4-1f87d1bbe8d3)
Grafhql Query is POST http://localhost:3000/graphql
Regards, Alex.