Skip to content

Commit

Permalink
changes the insert to be proper
Browse files Browse the repository at this point in the history
  • Loading branch information
priyanshi-yb committed Jan 10, 2025
1 parent c996e46 commit 7025d2c
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,44 @@
"exported_updates": 0,
"exported_deletes": 0,
"final_row_count": 2
},
{
"table_name": "public.\"null_and_default\"",
"db_type": "source",
"exported_snapshot_rows": 17,
"imported_snapshot_rows": 0,
"imported_inserts": 0,
"imported_updates": 0,
"imported_deletes": 0,
"exported_inserts": 2,
"exported_updates": 3,
"exported_deletes": 0,
"final_row_count": 19
},
{
"table_name": "public.\"null_and_default\"",
"db_type": "source-replica",
"exported_snapshot_rows": 0,
"imported_snapshot_rows": 17,
"imported_inserts": 2,
"imported_updates": 3,
"imported_deletes": 0,
"exported_inserts": 0,
"exported_updates": 0,
"exported_deletes": 0,
"final_row_count": 19
},
{
"table_name": "public.\"null_and_default\"",
"db_type": "target",
"exported_snapshot_rows": 17,
"imported_snapshot_rows": 0,
"imported_inserts": 2,
"imported_updates": 3,
"imported_deletes": 0,
"exported_inserts": 0,
"exported_updates": 0,
"exported_deletes": 0,
"final_row_count": 19
}
]
2 changes: 1 addition & 1 deletion migtests/tests/pg/datatypes/export_data_status-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"exported_count": 2
},
{
"exported_count": 13,
"exported_count": 17,
"status": "DONE",
"table_name": "hstore_example"
}
Expand Down
4 changes: 2 additions & 2 deletions migtests/tests/pg/datatypes/import_data_status-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
{
"table_name": "public.\"hstore_example\"",
"status": "DONE",
"total_count": 13,
"imported_count": 13,
"total_count": 17,
"imported_count": 17,
"percentage_complete": 100
},
{
Expand Down
10 changes: 5 additions & 5 deletions migtests/tests/pg/datatypes/pg_datatypes_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ VALUES
"language" => "English",
"ISBN-13" => "978-1449370000",
"weight" => "11.2 ounces"'),
(hstore(ROW(1,'{\"key1=value1, key2=value2\"}'))),
(hstore('json_field', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}')),
(hstore('{"key1=value1, key2=value2"}', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}')),
(hstore('"{""key1"":""value1"",""key2"":""value2""}"', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}')),
(hstore('"{key1:value1,key2:value2}"', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}'));
(hstore(ROW(1,'{"key1=value1, key2=value2"}'))),
(hstore('json_field', '{"key1=value1, key2={"key1=value1, key2=value2"}"}')), --hstore() key and values need no extra processing
('"{\"key1=value1, key2=value2\"}"=>"{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}"'), --single quotes string need to escaped properly
(hstore('"{""key1"":""value1"",""key2"":""value2""}"', '{"key1=value1, key2={"key1=value1, key2=value2"}"}')),
(hstore('"{key1:value1,key2:value2}"', '{"key1=value1, key2={"key1=value1, key2=value2"}"}'));
8 changes: 6 additions & 2 deletions migtests/tests/pg/datatypes/source_delta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ SET data = data || 'key3 => value3'
WHERE id = 1;

UPDATE hstore_example
SET data = hstore('{"key1=value1, key2=value2"}', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}')
SET data = hstore('{"key1=value1, key2=value2"}', '{"key1=value1, key2={"key1=value1, key2=value2"}"}')
WHERE id = 3;

UPDATE hstore_example
SET data = '"{\"key1=value1, key2=value2\"}"=>"{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}"'
WHERE id = 7;

INSERT INTO hstore_example (data)
VALUES
('key5 => value5, key6 => value6');

INSERT INTO hstore_example (data)
VALUES
(hstore('{"key1=value1, key2=value2"}', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}'));
(hstore('{"key1=value1, key2=value2"}', '{"key1=value1, key2={"key1=value1, key2=value2"}"}'));
28 changes: 18 additions & 10 deletions migtests/tests/pg/datatypes/target_delta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,24 @@ SET v1 = '{"new": "data"}', v2 = B'1111000011', v5=B'001010100101010101010101010
DELETE FROM datatypes2
WHERE 5 = ANY(v3);

INSERT INTO hstore_example (data)
VALUES
('key7 => value7, key8 => value8');
-- INSERT INTO hstore_example (data)
-- VALUES
-- ('key7 => value7, key8 => value8');

UPDATE hstore_example
SET data = delete(data, 'key2')
WHERE id = 8;
-- UPDATE hstore_example
-- SET data = delete(data, 'key2')
-- WHERE id = 8;

DELETE FROM hstore_example WHERE data ? 'key5';
-- DELETE FROM hstore_example WHERE data ? 'key5';

INSERT INTO hstore_example (data)
VALUES
(hstore('"{""key1"":""value1"",""key2"":""value2""}"', '{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}'));
-- INSERT INTO hstore_example (data)
-- VALUES
-- (hstore('"{""key1"":""value1"",""key2"":""value2""}"', '{"key1=value1, key2={"key1=value1, key2=value2"}"}'));

-- UPDATE hstore_example
-- SET data = hstore('{"key1=value1, key2=value2"}', '{"key1=value1, key2={"key1=value1, key2=value2"}"}')
-- WHERE id = 15;

-- UPDATE hstore_example
-- SET data = '"{\"key1=value1, key2=value2\"}"=>"{\"key1=value1, key2={\"key1=value1, key2=value2\"}\"}"'
-- WHERE id = 14;
2 changes: 1 addition & 1 deletion migtests/tests/pg/datatypes/validate
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ EXPECTED_ROW_COUNT = {
'datetime_type2': 2,
'null_and_default' :2,
'decimal_types': 3,
'hstore_example': 13,
'hstore_example': 17,
}

EXPECTED_SUM_OF_COLUMN = {
Expand Down
4 changes: 2 additions & 2 deletions migtests/tests/pg/datatypes/validateAfterChanges
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ EXPECTED_ROW_COUNT = {
'datetime_type2': 2,
'null_and_default' :2,
'decimal_types': 4,
'hstore_example': 16,
'hstore_example': 19,
}

EXPECTED_SUM_OF_COLUMN = {
Expand Down Expand Up @@ -66,7 +66,7 @@ EXPECTED_ROW_COUNT_FF = {
'datetime_type2': 3,
'null_and_default' :2,
'decimal_types': 4,
'hstore_example': 16,
'hstore_example': 19,
}

EXPECTED_SUM_OF_COLUMN_FF = {
Expand Down

0 comments on commit 7025d2c

Please sign in to comment.