diff --git a/README.md b/README.md index 78d53e1..b8a79a3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

-Surrealist is a Python tool to work with awesome [SurrealDB](https://docs.surrealdb.com/docs/intro) (support for latest version 2.1.1) +Surrealist is a Python tool to work with awesome [SurrealDB](https://docs.surrealdb.com/docs/intro) (support for latest version 2.1.2) It is **synchronous** and **unofficial**, so if you need async AND/OR official client, go [here](https://github.com/surrealdb/surrealdb.py) @@ -22,7 +22,7 @@ Works and tested on Ubuntu, macOS, Windows 10, can use python 3.8+ (including py * only one small dependency (websocket-client), no need to pull a lot of libraries to your project * fully documented * well tested (on the latest Ubuntu, macOS and Windows 10) - * fully compatible with the latest version of SurrealDB (2.1.1), including [live queries](https://surrealdb.com/products/lq) and [change feeds](https://surrealdb.com/products/cf) + * fully compatible with the latest version of SurrealDB (2.1.2), including [live queries](https://surrealdb.com/products/lq) and [change feeds](https://surrealdb.com/products/cf) * debug mode to see all that goes in and out if you need (using standard logging) * iterator to handle big select queries * QL-builder to explore, generate and use SurrealDB queries (explain, transaction etc.) @@ -168,13 +168,14 @@ from surrealist import Database # connects to Database (it is not connection) with Database("http://127.0.0.1:8000", 'test', 'test', credentials=("user_db", "user_db")) as db: table = db.table("person") # switch to table level, no problem if it is not exists + print(table.count()) # 0, table is empty or not exists # let's add record # real query CREATE person:john SET status = "ACTIVE" RETURN id; result = table.create("john").set(status="ACTIVE").returns("id").run() # SurrealResult(id=9eb966a4-02fc-40ea-82ba-825d37254f43, status=OK, result=[{'id': 'person:john'}], # query=CREATE person:john SET status = "ACTIVE" RETURN id;, code=None, time=110.3µs, additional_info={}) print(result) - print(table.count()) # 1 record + print(table.count()) # now one record ``` You can find QL examples [here](https://github.com/kotolex/surrealist/tree/master/examples/surreal_ql) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 7497688..d958869 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,4 +1,7 @@ ## Release Notes ## +**Version 1.0.7 (compatible with SurrealDB version 2.1.2):** +- fix tests and examples + **Version 1.0.6 (compatible with SurrealDB version 2.1.1):** - versionstamp is now can be used in SINCE statement for SHOW - by default, if no SINCE were specified Show statement generates SINCE 1 diff --git a/examples/surreal_ql/ql_crud.py b/examples/surreal_ql/ql_crud.py index d8bcb30..e8dbd63 100644 --- a/examples/surreal_ql/ql_crud.py +++ b/examples/surreal_ql/ql_crud.py @@ -3,6 +3,7 @@ with Database("http://127.0.0.1:8000", 'test', 'test', credentials=("user_db", "user_db")) as db: print(db.tables()) # [] cause database is empty table = db.table("person") # even there is no such table yes it is OK to switch on it + print(table.count()) # and even get count of records which is 0 for non-existent table # now let's create one record via set statement result = table.create().set(name="Alex", age=30, active=True).run() # pay attention how we use keyword parameters print(result.result) # [{'active': True, 'age': 30, 'id': 'person:wfulrb7dqml3vv7koqnb', 'name': 'Alex'}] diff --git a/pyproject.toml b/pyproject.toml index 1ec3ac9..20496a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "surrealist" -version = "1.0.6" +version = "1.0.7" description = "Python client for SurrealDB, latest SurrealDB version compatible, all features supported" readme = "README.md" authors = [{ name = "kotolex", email = "farofwell@gmail.com" }] diff --git a/tests/integration_tests/test_http_connection.py b/tests/integration_tests/test_http_connection.py index eb09190..24600df 100644 --- a/tests/integration_tests/test_http_connection.py +++ b/tests/integration_tests/test_http_connection.py @@ -286,7 +286,8 @@ def test_count(self): with surreal.connect() as connection: connection.use("test", "test") res = connection.count("not_exists") - self.assertTrue(res.is_error(), res) + self.assertFalse(res.is_error()) + self.assertEqual(0, res.result) self.assertEqual("SELECT count() FROM not_exists GROUP ALL;", res.query) count = connection.count("article").result uid = get_random_series(6) @@ -294,12 +295,13 @@ def test_count(self): new_count = connection.count("article").result self.assertEqual(new_count, count + 1) - def test_count_is_error_if_wrong(self): + def test_count_is_zero_if_wrong(self): surreal = Surreal(URL, credentials=('root', 'root'), use_http=True) with surreal.connect() as connection: connection.use("test", "test") res = connection.count("wrong") - self.assertTrue(res.is_error()) + self.assertFalse(res.is_error()) + self.assertEqual(0, res.result) def test_count_returns_fields(self): surreal = Surreal(URL, credentials=('root', 'root'), use_http=True) diff --git a/tests/integration_tests/test_ws_connection.py b/tests/integration_tests/test_ws_connection.py index efb39ca..389add6 100644 --- a/tests/integration_tests/test_ws_connection.py +++ b/tests/integration_tests/test_ws_connection.py @@ -284,7 +284,8 @@ def test_count(self): with surreal.connect() as connection: connection.use("test", "test") res = connection.count("not_exists") - self.assertTrue(res.is_error()) + self.assertFalse(res.is_error()) + self.assertEqual(0, res.result) self.assertEqual("SELECT count() FROM not_exists GROUP ALL;", res.query) count = connection.count("article").result uid = get_random_series(6) @@ -292,12 +293,13 @@ def test_count(self): new_count = connection.count("article").result self.assertEqual(new_count, count + 1) - def test_count_is_error_if_wrong(self): + def test_count_is_zero_if_wrong(self): surreal = Surreal(URL, credentials=('root', 'root')) with surreal.connect() as connection: connection.use("test", "test") res = connection.count("wrong") - self.assertTrue(res.is_error()) + self.assertFalse(res.is_error()) + self.assertEqual(0, res.result) def test_count_returns_fields(self): surreal = Surreal(URL, credentials=('root', 'root'))