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

use db_version for col_version #386

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 core/rs/core/src/tableinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl TableInfo {
?,
0 WHERE true
ON CONFLICT DO UPDATE SET
col_version = col_version + 1,
col_version = crsql_next_db_version(),
db_version = ?,
seq = ?,
site_id = 0;",
Expand Down
2 changes: 1 addition & 1 deletion py/correctness/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# source env/bin/activate
# python -m pytest tests -s -k test_cl_merging
python3 -m pytest tests -s
python3 -m pytest tests -s
10 changes: 6 additions & 4 deletions py/correctness/tests/test_cl_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def test_larger_cl_wins_all():
c1.commit()

c2.execute("INSERT INTO foo VALUES (1, 1)")
c2.commit()
c2.execute("UPDATE foo SET b = 3 WHERE a = 1")
c2.commit()
c2.execute("UPDATE foo SET b = 4 WHERE a = 1")
c2.commit()

Expand All @@ -118,7 +120,7 @@ def test_larger_cl_wins_all():
assert (c1.execute(
"SELECT col_version, cl FROM crsql_changes WHERE cid = 'b'").fetchone() == (1, 3))

# c2 hard col_version = 3 given insert + 2 updates
# c2 had col_version = 3 given insert + 2 updates
# an cl = 1 given a single isnert
assert (c2.execute(
"SELECT col_version, cl FROM crsql_changes WHERE cid = 'b'").fetchone() == (3, 1))
Expand Down Expand Up @@ -996,15 +998,15 @@ def make_schema():
# make sure we have the expected change coming out of node C
assert (c.execute(
"SELECT cid, col_version, cl FROM crsql_changes WHERE db_version = 4").fetchall() ==
[('b', 2, 3), ('c', 2, 3)])
[('b', 4, 3), ('c', 4, 3)])

# a received the delete followed by updates of cells `b` and `c`
# so it's changes should only have:
# 1. the sentinal with causal length 3
# 2. cell b with col version 2 and causal length 3
# 2. cell b with col version 4 and causal length 3
# 3. cell c with the same
assert (a.execute("SELECT cid, col_version, cl FROM crsql_changes").fetchall(
) == [('-1', 3, 3), ('b', 2, 3), ('c', 2, 3)])
) == [('-1', 3, 3), ('b', 4, 3), ('c', 4, 3)])

# now that old re-insert goes to A
sync_left_to_right_single_vrsn(c, a, 3)
Expand Down