Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

*_by_sql methods do not work in historical queries #313

Open
tagliala opened this issue Jun 8, 2024 · 0 comments
Open

*_by_sql methods do not work in historical queries #313

tagliala opened this issue Jun 8, 2024 · 0 comments
Labels
CRITICAL Critical issues limitation

Comments

@tagliala
Copy link
Member

tagliala commented Jun 8, 2024

Finding *_by_sql does not work on historical queries

Country.as_of(1.day.ago).first.name
  Country Load (3.2ms)  SELECT "countries".* FROM (SELECT "history"."countries".* FROM "history"."countries" WHERE ( '2024-06-07 15:28:39.371662'::timestamp <@ history.countries.validity )) "countries" ORDER BY "countries"."id" ASC LIMIT $1  [["LIMIT", 1]]
=> "France"

> Country.first.name
  Country Load (0.6ms)  SELECT "countries".* FROM "countries" ORDER BY "countries"."id" ASC LIMIT $1  [["LIMIT", 1]]
=> "France 2"
Country.as_of(1.day.ago).find_by_sql('select * from countries where name = \'France\'')
  Country Load (0.5ms)  select * from countries where name = 'France'
=> []
> Country.find_by_sql("select * from countries where name = 'France 2'")
  Country Load (1.2ms)  select * from countries where name = 'France 2'
=> [#<Country:0x000000012e2a7310
  id: 1,
  name: "France 2",
  my_date: nil,
  created_at: Mon, 27 May 2024 07:25:26.527623000 UTC +00:00,
  updated_at: Sat, 08 Jun 2024 15:27:52.027120000 UTC +00:00>]
@tagliala tagliala added bug CRITICAL Critical issues labels Jun 8, 2024
tagliala added a commit that referenced this issue Jun 9, 2024
@tagliala tagliala changed the title find_by_sql does not work in historical queries *_by_sql methods do not work in historical queries Jun 9, 2024
tagliala added a commit that referenced this issue Jun 9, 2024
@tagliala tagliala added limitation and removed bug labels Jun 11, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CRITICAL Critical issues limitation
Projects
None yet
Development

No branches or pull requests

1 participant