Sha256: 2fda61680d4f9c197416f58028d01ec3b7e6aeebfe15bcdddbc86f86c123ea98

Contents?: true

Size: 1.8 KB

Versions: 13

Compression:

Stored size: 1.8 KB

Contents

Feature: Import a CSV file into the database with merging

  The merge_on property can be used to specify an id field that is used to detect duplicates while importing.
  Duplicates are updated and new items are added.

  Scenario: Successful import with merged items
    Given a database table called "dim_product" with the following fields:
      | field_name  | field_type |
      | item        | TEXT       |
      | title       | TEXT       |
      | description | TEXT       |
    And only the following rows in the "dim_product" database table:
      | item    | title                | description                  |
      | JNI-123 | Just a product name  | Very interesting description |
      | CDI-234 | Another product name | Yet another cool description |
    And a "products.csv" data file containing:
    """
    id,name,description
    JNI-123,Just a product name,"Very interesting description, updated"
    CDI-234,Updated product name,Yet another cool description
    KLM-987,Inserted product name,This is the best product
    """
    And the following definition:
    """
    source :products do
      field :id, String
      field :name, String
      field :description, String
    end

    import :products do
      into :dim_product
      put :id => :item
      put :name => :title
      put :description => :description

      merge_on :id => :item
    end
    """
    When I execute the definition
    Then the process should exit successfully
    And the "dim_product" table should contain:
      | item    | title                 | description                           |
      | JNI-123 | Just a product name   | Very interesting description, updated |
      | CDI-234 | Updated product name  | Yet another cool description          |
      | KLM-987 | Inserted product name | This is the best product              |

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cranium-0.8.1 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.8 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.7 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.6.1 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.5 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.4.3 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.4.2 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.4.1 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.4 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.3.1 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.3.0 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.2.1 features/import/import_csv_to_database_with_update_merging.feature
cranium-0.2.0 features/import/import_csv_to_database_with_update_merging.feature