Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDC #321 - Import UDFs #111

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/taxonomies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def transform

execute <<-SQL.squish
UPDATE #{table_name} z_taxonomies
SET taxonomy_id = taxonomies.id
SET taxonomy_id = taxonomies.id,
user_defined = taxonomies.user_defined
FROM core_data_connector_taxonomies taxonomies
WHERE taxonomies.uuid = z_taxonomies.uuid
SQL
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