Skip to content

Commit 86bd634

Browse files
committed
Remove ID from attributes in update! method for CQL::ActiveRecord
- Updated the update! method to delete the ID from both record attributes and update attributes before processing updates, ensuring that the ID is not included in the update operation.
1 parent 0650da4 commit 86bd634

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/active_record/updateable.cr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ module CQL
8888
def self.update!(record : {{@type.id}})
8989
attrs = record.attributes
9090

91+
# Remove the ID from the attributes
92+
attrs.delete(:id)
93+
9194
# Update the record
9295
CQL::Update
9396
.new({{@type.id}}.schema)
@@ -112,6 +115,10 @@ module CQL
112115
where_attrs : Hash(Symbol, DB::Any),
113116
update_attrs : Hash(Symbol, DB::Any)
114117
)
118+
119+
# Remove the ID from the attributes
120+
update_attrs.delete(:id)
121+
115122
CQL::Update
116123
.new({{@type.id}}.schema)
117124
.table({{@type.id}}.table)

0 commit comments

Comments
 (0)