[tx] Test that datom flags are written to SQL store correctly #119

Open
opened 2020-08-06 16:55:13 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:55:13 +00:00 (Migrated from github.com)

This is follow-up to #267 and similar to #268. What we want is tests to ensure the datoms table gets the correct index_* flags set, based on the attribute flags. The datoms schema is around 42580539b8/db/src/db.rs (L56).

To test this, use the existing transact code to transact assertions using some of the bootstrap attributes. Then use raw SQL to query the datoms table, following the examples in 42580539b8/db/src/debug.rs. (You might add a helper there to produce EDN for the "full" or "raw" datoms, making this a little easier to test, and possibly helping later on when we want to compare other parts of the raw tables.)

The interesting cases are:

  • attribute is :db/index true => datom has index_avet = 1
  • attribute is :db/valueType :db.type/ref => datom has index_vaet = 1
  • attribute is :db/fulltext true => datom has index_fulltext = 1 Note: this can't be tested yet, since fulltext datoms aren't yet supported!
  • attribute is :db/unique :db.unique/value => datom has unique_value = 1

Check the positive and negative cases for each of those, and we're good! This is a pretty good first bug, I think, since there's lots of code similar to this in the tree already.

This is follow-up to #267 and similar to #268. What we want is tests to ensure the `datoms` table gets the correct `index_*` flags set, based on the attribute flags. The `datoms` schema is around https://github.com/mozilla/mentat/blob/42580539b8a58f9d10e5891a22112f8c1b697bff/db/src/db.rs#L56. To test this, use the existing transact code to transact assertions using some of the bootstrap attributes. Then use raw SQL to query the `datoms` table, following the examples in https://github.com/mozilla/mentat/blob/42580539b8a58f9d10e5891a22112f8c1b697bff/db/src/debug.rs. (You might add a helper there to produce EDN for the "full" or "raw" datoms, making this a little easier to test, and possibly helping later on when we want to compare other parts of the raw tables.) The interesting cases are: - attribute is `:db/index true` => datom has `index_avet = 1` - attribute is `:db/valueType :db.type/ref` => datom has `index_vaet = 1` - attribute is `:db/fulltext true` => datom has `index_fulltext = 1` **Note: this can't be tested yet, since fulltext datoms aren't yet supported!** - attribute is `:db/unique :db.unique/value` => datom has `unique_value = 1` Check the positive and negative cases for each of those, and we're good! This is a pretty good first bug, I think, since there's lots of code similar to this in the tree already.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#119
No description provided.