chronomodel
chronomodel copied to clipboard
`*_by_sql` methods do not work in historical queries
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>]