https://github.com/daddye/gocqltest
Test nulls
https://github.com/daddye/gocqltest
Last synced: 8 months ago
JSON representation
Test nulls
- Host: GitHub
- URL: https://github.com/daddye/gocqltest
- Owner: DAddYE
- Created: 2014-12-18T23:11:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-19T06:25:09.000Z (over 11 years ago)
- Last Synced: 2025-05-14T13:18:46.821Z (about 1 year ago)
- Language: Go
- Size: 125 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## TEST NULL's issue
If you have at least one instance of cassandra running just:
```
$ go get github.com/daddye/gocqltest
$ cd $GOPATH/src/github.com/daddye/gocqltest
$ make
```
This command will create drop/create the keyspace for and run the test.
### The Test:
Seems that `prepared` statements [[1]](https://github.com/gocql/gocql/issues/296) [[2]](https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/cHE3OOSIXBU/discussion) [[3]](https://issues.apache.org/jira/browse/CASSANDRA-7304)
(defaults in gocql) suffers of a "bug" where *not* setting a *column* means setting it `NULL` which
causes the creation of a tombstone in cassandra if we do that query with prepared statements.
This problem _seems_ amplified with _arrays_ (slices). Basically an empty slice is `nil` for go and
so `null` for cassandra. Again, if I understood correctly the
[jira](https://issues.apache.org/jira/browse/CASSANDRA-7304) this in conjunction with prepared
statements would cause a creation of a tombstone.
So right now the output will be:
```
cqlsh -e "DROP KEYSPACE IF EXISTS gocqltest"
cqlsh -f schema.cql
go run main.go
cqlsh -e "SELECT * FROM gocqltest.test"
id | categories | name | status
----+------------+------+--------
5 | null | null | null
10 | null | null | null
16 | null | null | null
13 | null | null | null
11 | null | null | null
1 | null | null | null
19 | null | null | null
8 | null | null | null
0 | null | null | null
2 | null | null | null
4 | null | null | null
18 | null | null | null
15 | null | null | null
7 | null | null | null
6 | null | null | null
9 | null | null | null
14 | null | null | null
17 | null | null | null
12 | null | null | null
3 | null | null | null
(20 rows)
```
Which according to [jira](https://issues.apache.org/jira/browse/CASSANDRA-7304) would create
tombstones (probably when you use more than one node) in cassandra since gocql comes with prepared
statements by default.