PNixx / clickhouse-activerecord

A Ruby database ActiveRecord driver for ClickHouse
MIT License
202 stars 100 forks source link

Update record field #155

Closed xao0isb closed 3 months ago

xao0isb commented 3 months ago

Is there any way to update record field? If I use update or change the value of a record and then run save the value in database remains the same.

PNixx commented 3 months ago

Gem version?

PNixx commented 3 months ago

Already support in latest versions https://github.com/PNixx/clickhouse-activerecord/blob/master/spec/single/model_spec.rb#L72-L86

xao0isb commented 3 months ago

I'm using latest version

record = Model.create(value: "abc")
pp record.value # "abc"

record.update!(value: "123")
pp record.value # "123"

pp Model.last.value # "abc" and not "123"

@PNixx

xao0isb commented 3 months ago

@PNixx reopen issue, please

PNixx commented 3 months ago

Need more details: ClickHouse version, table structure and engine.

xao0isb commented 3 months ago

Am I doing something wrong with table creation? I don't get deep into clickhouse yet and now just want to test it out.

PNixx commented 3 months ago

I ran the test and it completed successfully with a one second pause. You need to wait some time before receiving data from the database. Updating and deleting in Clickhouse should only be used in extreme cases https://clickhouse.com/docs/en/guides/developer/mutations

image