Data sync record key update #44

Closed
opened 2020-02-10 22:59:34 +00:00 by jamie · 6 comments
jamie commented 2020-02-10 22:59:34 +00:00 (Migrated from git.hazaar.io)

Right now we have two methods for detecting existing rows in a table.

Methods

Primary key

If the primary key is defined in the data sync record, this is used to identify an existing row. If the key exists, then an update is performed using the data in the data sync record. If they key does not exist, then a new row is inserted with the data sync record.

Record data

If the primary key is NOT defined in the data sync record then the entire record is used to identify an existing row. This can be used to ensure that the data sync record exists in the database table as it is defined in the data sync file.

Caveats

For primary key, if the key is defined in multiple records then there is a chance that data will be overwritten each time a sync is performed. For record data, because the entire record is used, it is possible that an entirely new record will be recreated if even a single field changes in the data sync file.

Solution

Data key specifiers. In the data sync table object we can add a new attribute called keys that will define the keys to be used to identify existing rows. This will default to the primary key if this attribute does not exist. The attribute can be defined as an array of column names used to find existing rows. This will work almost exactly as the other methods but will allow a record with say, 2 columns matching to be considered the existing row.

Right now we have two methods for detecting existing rows in a table. # Methods ## Primary key If the primary key is defined in the data sync record, this is used to identify an existing row. If the key exists, then an update is performed using the data in the data sync record. If they key does not exist, then a new row is inserted with the data sync record. ## Record data If the primary key is NOT defined in the data sync record then the entire record is used to identify an existing row. This can be used to ensure that the data sync record exists in the database table as it is defined in the data sync file. # Caveats For *primary key*, if the key is defined in multiple records then there is a chance that data will be overwritten each time a sync is performed. For *record data*, because the entire record is used, it is possible that an entirely new record will be recreated if even a single field changes in the data sync file. # Solution Data key specifiers. In the data sync table object we can add a new attribute called *keys* that will define the keys to be used to identify existing rows. This will default to the primary key if this attribute does not exist. The attribute can be defined as an array of column names used to find existing rows. This will work almost exactly as the other methods but will allow a record with say, 2 columns matching to be considered the existing row.
jamie commented 2020-02-10 23:29:40 +00:00 (Migrated from git.hazaar.io)

mentioned in issue #45

mentioned in issue #45
jamie commented 2020-02-11 04:21:40 +00:00 (Migrated from git.hazaar.io)

created merge request !18 to address this issue

created merge request !18 to address this issue
jamie commented 2020-02-11 04:21:40 +00:00 (Migrated from git.hazaar.io)

mentioned in merge request !18

mentioned in merge request !18
jamie commented 2020-02-11 06:00:29 +00:00 (Migrated from git.hazaar.io)

closed via merge request !18

closed via merge request !18
jamie commented 2020-02-11 06:00:29 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 75c6f29078

mentioned in commit 75c6f290785692afed0526f2f4dd13cdabcbb005
jamie commented 2020-02-13 06:16:10 +00:00 (Migrated from git.hazaar.io)

mentioned in issue #47

mentioned in issue #47
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/hazaar-dbi#44
No description provided.