Skip to content

Commit

Permalink
Fix incorrect set of sequence val after exporting database (#4636)
Browse files Browse the repository at this point in the history
* fix incorrect set of sequence val after exporting database

* add test case
  • Loading branch information
ray6080 authored Dec 16, 2024
1 parent 73540dc commit 24e669d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/catalog/catalog_entry/sequence_catalog_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ std::unique_ptr<SequenceCatalogEntry> SequenceCatalogEntry::deserialize(

std::string SequenceCatalogEntry::toCypher(main::ClientContext* /*clientContext*/) const {
return stringFormat(
"DROP SEQUENCE IF EXISTS {};\n"
"CREATE SEQUENCE IF NOT EXISTS {} START {} INCREMENT {} MINVALUE {} MAXVALUE {} {} CYCLE;\n"
"RETURN nextval('{}');",
getName(), sequenceData.currVal, sequenceData.increment, sequenceData.minValue,
getName(), getName(), sequenceData.currVal, sequenceData.increment, sequenceData.minValue,
sequenceData.maxValue, sequenceData.cycle ? "" : "NO", getName());
}

Expand Down
16 changes: 16 additions & 0 deletions test/test_files/copy/export_import_db.test
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ Imported database successfully.
---- 2
0
1
-STATEMENT CREATE (o:twoserial {prop: "Dan2"})
---- ok
-STATEMENT CREATE (o:oneserial)
---- ok
-STATEMENT MATCH (o:twoserial) RETURN o.*;
---- 5
0|Alice
1|Bob
2|Carol
3|Dan
4|Dan2
-STATEMENT MATCH (o:oneserial) RETURN o.*;
---- 3
0
1
2

-CASE DocExportImportExampleCSV
-SKIP_WASM
Expand Down

0 comments on commit 24e669d

Please sign in to comment.