Skip to content

Commit

Permalink
Merge pull request #111 from performant-software/feature/cdc321_impor…
Browse files Browse the repository at this point in the history
…t_udfs

CDC #321 - Import UDFs
  • Loading branch information
dleadbetter authored Jan 3, 2025
2 parents bbec41f + 1fb6a07 commit 1966f62
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/services/core_data_connector/export/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def to_export_csv(user_defined_fields)
private

def add_user_defined_fields(hash, user_defined_fields)
return unless user_defined_fields.present? && self.respond_to?(:user_defined)
return unless user_defined_fields.present? && self.respond_to?(:user_defined) && self.user_defined.present?

user_defined_fields.each do |user_defined_field|
key = ImportAnalyze::Helper.uuid_to_column_name(user_defined_field.uuid)
Expand Down
2 changes: 1 addition & 1 deletion app/services/core_data_connector/import/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name}
SET user_defined = json_strip_nulls(json_build_object(#{expression}))
SET user_defined = user_defined || json_strip_nulls(json_build_object(#{expression}))::jsonb
SQL

# Sets the "Select" and "FuzzyDate" user-defined types to JSONB
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_events
SET event_id = events.id
SET event_id = events.id,
user_defined = events.user_defined
FROM core_data_connector_events events
WHERE events.uuid = z_events.uuid
SQL
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_instances
SET instance_id = instances.id
SET instance_id = instances.id,
user_defined = instances.user_defined
FROM core_data_connector_instances instances
WHERE instances.uuid = z_instances.uuid
SQL
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_items
SET item_id = items.id
SET item_id = items.id,
user_defined = items.user_defined
FROM core_data_connector_items items
WHERE items.uuid = z_items.uuid
SQL
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_organizations
SET organization_id = organizations.id
SET organization_id = organizations.id,
user_defined = organizations.user_defined
FROM core_data_connector_organizations organizations
WHERE organizations.uuid = z_organizations.uuid
SQL
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/people.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_people
SET person_id = people.id
SET person_id = people.id,
user_defined = people.user_defined
FROM core_data_connector_people people
WHERE people.uuid = z_people.uuid
SQL
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/places.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_places
SET place_id = places.id
SET place_id = places.id,
user_defined = places.user_defined
FROM core_data_connector_places places
WHERE places.uuid = z_places.uuid
SQL
Expand Down
6 changes: 4 additions & 2 deletions app/services/core_data_connector/import/relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_relationships
SET relationship_id = relationships.id
SET relationship_id = relationships.id,
user_defined = relationships.user_defined
FROM core_data_connector_relationships relationships
WHERE relationships.uuid = z_relationships.uuid
AND z_relationships.relationship_id IS NULL
SQL

execute <<-SQL.squish
UPDATE #{table_name} z_relationships
SET relationship_id = relationships.id
SET relationship_id = relationships.id,
user_defined = relationships.user_defined
FROM core_data_connector_relationships relationships
WHERE relationships.primary_record_id = z_relationships.primary_record_id
AND relationships.primary_record_type = z_relationships.primary_record_type
Expand Down
3 changes: 2 additions & 1 deletion app/services/core_data_connector/import/works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_works
SET work_id = works.id
SET work_id = works.id,
user_defined = works.user_defined
FROM core_data_connector_works works
WHERE works.uuid = z_works.uuid
SQL
Expand Down

0 comments on commit 1966f62

Please sign in to comment.