Data sync record column macros #45

Closed
opened 2020-02-10 23:29:40 +00:00 by jamie · 6 comments
jamie commented 2020-02-10 23:29:40 +00:00 (Migrated from git.hazaar.io)

There are cases where we may want to put data from another table into a column when syncing a record. An example would be looking up the id of another record to use in the record being synced. Previously this would mean that all these primary and foreign keys would have to be defined manually. With issue #44 on the way, we will be able to add records based on non-primary keys and therefore we will need a way of looking up these values to use as foreign key data.

I'm not exactly sure how to define these macros as we don't want to interfer with any possible data being inserted/updated.

There are cases where we may want to put data from another table into a column when syncing a record. An example would be looking up the *id* of another record to use in the record being synced. Previously this would mean that all these primary and foreign keys would have to be defined manually. With issue #44 on the way, we will be able to add records based on non-primary keys and therefore we will need a way of looking up these values to use as foreign key data. I'm not exactly sure how to define these macros as we don't want to interfer with any possible data being inserted/updated.
jamie commented 2020-02-12 00:00:36 +00:00 (Migrated from git.hazaar.io)

I have decided to go with the following format for the macros:

{
  "target_column": "::source_talble(source_column):criteria",
}
        

Where:

  • source_table is the table to lookup data from.
  • source_column is the name of the column to use for data.
  • criteria is a basic selection criteria such as column1=value1,column2=value2.

For example, to take the id column from the request_type table from a row where name is set to registration.

{
  "request_type_id": "::request_type(id):name=registration",
  "name": "submitted",
  "label": "Request Submitted"
}
        

This would allow a previous data sync row to add the registration request type and then we can use it's primary key column id as the value for this column.

I have decided to go with the following format for the macros: ```json { "target_column": "::source_talble(source_column):criteria", } ``` Where: * `source_table` is the table to lookup data from. * `source_column` is the name of the column to use for data. * `criteria` is a basic selection criteria such as `column1=value1,column2=value2`. For example, to take the `id` column from the `request_type` table from a row where `name` is set to `registration`. ```json { "request_type_id": "::request_type(id):name=registration", "name": "submitted", "label": "Request Submitted" } ``` This would allow a previous data sync row to add the `registration` request type and then we can use it's primary key column `id` as the value for this column.
jamie commented 2020-02-12 00:40:04 +00:00 (Migrated from git.hazaar.io)

created merge request !19 to address this issue

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

mentioned in merge request !19

mentioned in merge request !19
jamie commented 2020-02-12 01:42:31 +00:00 (Migrated from git.hazaar.io)

closed via merge request !19

closed via merge request !19
jamie commented 2020-02-12 01:42:31 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 00bf03f18d

mentioned in commit 00bf03f18df46f5ad299db34835b6a2873d0f012
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#45
No description provided.