#!/usr/bin/env bats load $BATS_TEST_DIRNAME/helper/common.bash setup() { setup_common dolt sql < 12 and to_pk < 30;" [ $status -eq 0 ] [[ "${#lines[@]}" = "6" ]] # 2 rows + 4 formatting lines [[ "$output" =~ "| NULL | 22 | added |" ]] || false [[ "$output" =~ "| 21 | 21 | modified |" ]] || false run dolt sql -q "describe plan select * from dolt_commit_diff_test where from_commit = DOLT_HASHOF('create') and to_commit = DOLT_HASHOF('head') and to_pk > 0 and to_pk < 5;" [ $status -eq 0 ] [[ "$output" =~ "index: [dolt_commit_diff_test.to_commit,dolt_commit_diff_test.from_commit,dolt_commit_diff_test.to_pk]" ]] || false [[ "$output" =~ "(0, 5)" ]] || false run dolt sql -q "select from_pk1, from_pk2, to_pk1, to_pk2, diff_type from dolt_commit_diff_test_two_pk where from_commit = DOLT_HASHOF('initial') and to_commit = DOLT_HASHOF('update') and to_pk1 = 2;" [ $status -eq 0 ] [[ "${#lines[@]}" = "6" ]] # 2 rows + 4 formatting lines [[ "$output" =~ "| 2 | 21 | 2 | 21 | modified |" ]] || false [[ "$output" =~ "| NULL | NULL | 2 | 22 | added |" ]] || false run dolt sql -q "describe plan select * from dolt_commit_diff_test_two_pk where from_commit = DOLT_HASHOF('create') and to_commit = DOLT_HASHOF('head') and to_pk1 = 2;" [ $status -eq 0 ] [[ "$output" =~ "index: [dolt_commit_diff_test_two_pk.to_commit,dolt_commit_diff_test_two_pk.from_commit,dolt_commit_diff_test_two_pk.to_pk1,dolt_commit_diff_test_two_pk.to_pk2]" ]] || false [[ "$output" =~ "[2, 2], [NULL, ∞)" ]] || false } @test "sql-commit-diff: DOLT_COMMIT_DIFF with a range on from_ key" { run dolt sql -q "select from_pk, to_pk, diff_type from dolt_commit_diff_test where from_commit = DOLT_HASHOF('initial') and to_commit = DOLT_HASHOF('update') and from_pk > 12 and from_pk < 30;" [ $status -eq 0 ] [[ "${#lines[@]}" = "6" ]] # 2 rows + 4 formatting lines [[ "$output" =~ "| 20 | NULL | removed |" ]] || false [[ "$output" =~ "| 21 | 21 | modified |" ]] || false run dolt sql -q "describe plan select * from dolt_commit_diff_test where from_commit = DOLT_HASHOF('create') and to_commit = DOLT_HASHOF('head') and from_pk > 0 and from_pk < 5;" [ $status -eq 0 ] [[ "$output" =~ "index: [dolt_commit_diff_test.to_commit,dolt_commit_diff_test.from_commit,dolt_commit_diff_test.from_pk]" ]] || false [[ "$output" =~ "(0, 5)" ]] || false run dolt sql -q "select from_pk1, from_pk2, to_pk1, to_pk2, diff_type from dolt_commit_diff_test_two_pk where from_commit = DOLT_HASHOF('initial') and to_commit = DOLT_HASHOF('update') and from_pk1 = 2;" [ $status -eq 0 ] [[ "${#lines[@]}" = "6" ]] # 2 rows + 4 formatting lines [[ "$output" =~ "| 2 | 21 | 2 | 21 | modified |" ]] || false [[ "$output" =~ "| 2 | 20 | NULL | NULL | removed |" ]] || false run dolt sql -q "describe plan select * from dolt_commit_diff_test_two_pk where from_commit = DOLT_HASHOF('create') and to_commit = DOLT_HASHOF('head') and from_pk1 = 2;" [ $status -eq 0 ] [[ "$output" =~ "index: [dolt_commit_diff_test_two_pk.to_commit,dolt_commit_diff_test_two_pk.from_commit,dolt_commit_diff_test_two_pk.from_pk1,dolt_commit_diff_test_two_pk.from_pk2]" ]] || false [[ "$output" =~ "[2, 2], [NULL, ∞)" ]] || false }