Skip to content

Commit 6b7741d

Browse files
committed
Merge branch 'main' into v3-merge-with-main
# Conflicts: # .github/workflows/python-publish.yml # .github/workflows/tests.yaml # CHANGELOG.md # requirements.txt # setup.py # tests/aio/test_tx.py # tests/conftest.py # tests/table/test_tx.py # ydb/aio/table.py # ydb/convert.py # ydb/global_settings.py # ydb/table.py # ydb/types.py
2 parents f7aceb1 + fe07ae5 commit 6b7741d

File tree

15 files changed

+138
-30
lines changed

15 files changed

+138
-30
lines changed

.github/scripts/increment_version.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
SETUP_PY_PATH = "setup.py"
88
DEFAULT_CHANGELOG_PATH = "CHANGELOG.md"
9+
DEFAULT_YDB_VERSION_FILE = "ydb/ydb_version.py"
910
MARKER = "# AUTOVERSION"
1011

1112

@@ -125,6 +126,10 @@ def add_changelog_version(changelog_path, version: str):
125126
f.write(content)
126127

127128

129+
def set_version_in_ydb_version_file(file_path: str, version: str):
130+
with open(file_path, "w") as f:
131+
f.write('VERSION = "%s"\n' % version)
132+
128133
def main():
129134
parser = argparse.ArgumentParser()
130135
parser.add_argument(
@@ -147,6 +152,7 @@ def main():
147152

148153
new_version = increment_version_at_setup_py(args.setup_py_path, args.inc_type, is_beta)
149154
add_changelog_version(args.changelog_path, new_version)
155+
set_version_in_ydb_version_file(DEFAULT_YDB_VERSION_FILE, new_version)
150156
print(new_version)
151157

152158

.github/workflows/python-publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ jobs:
6969
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
7070
echo "New version: $NEW_VERSION" >> $GITHUB_STEP_SUMMARY
7171
72-
git add $SETUP_PY_PATH
73-
git add $CHANGELOG_FILE
74-
7572
- name: Build package
7673
run: python -m build
7774

@@ -93,7 +90,7 @@ jobs:
9390
9491
git config --global user.email "robot@umbrella";
9592
git config --global user.name "robot";
96-
git commit -m "Release: $TAG";
93+
git commit -am "Release: $TAG";
9794
9895
git tag "$TAG"
9996
git push && git push --tags

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@
3535
## 3.0.1b1 ##
3636
* start 3.0 beta branch
3737

38+
## 2.13.3 ##
39+
* fixed use transaction object when commit with flag
40+
41+
## 2.13.2 ##
42+
* fix snapshot attribute in class _ResultSet
43+
44+
## 2.13.1 ##
45+
* fixed set version in ydb_version file
46+
47+
## 2.13.0 ##
48+
* fixed in to make compressed backups possible
49+
* Add snapshot to read table responses
50+
51+
## 2.12.4 ##
52+
* Added functions for global change behaviour for compatible with future sdk version: ydb.global_allow_truncated_result and global_allow_split_transactions
53+
54+
## 2.12.3 ##
55+
* Flag for deny split transaction
56+
* Add six package to requirements
57+
* Fixed error while passing date parameter in execute
58+
59+
## 2.12.2 ##
60+
* Fix error of check retriable error for idempotent operations (error exist since 2.12.1)
61+
3862
## 2.12.1 ##
3963
* Supported `TYPE_UNSPECIFIED` item type to scheme ls
4064
* Fixed error while request iam token with bad content type in metadata

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
aiohttp>=3.7.4,<4.0.0
2-
enum-compat>=0.0.1
31
grpcio>=1.42.0
42
packaging
53
protobuf>=3.13.0,<5.0.0
6-
six<2
4+
pytest==6.2.4
5+
aiohttp==3.7.4

tests/aio/test_tx.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def test_tx_snapshot_ro(driver, database):
9898

9999

100100
@pytest.mark.asyncio
101-
async def test_split_transactions_deny_split(driver, table_name):
101+
async def test_split_transactions_deny_split_explicit_commit(driver, table_name):
102102
async with ydb.aio.SessionPool(driver, 1) as pool:
103103

104104
async def check_transaction(s: ydb.aio.table.Session):
@@ -118,6 +118,28 @@ async def check_transaction(s: ydb.aio.table.Session):
118118
await pool.retry_operation(check_transaction)
119119

120120

121+
@pytest.mark.asyncio
122+
async def test_split_transactions_deny_split_flag_commit(driver, table_name):
123+
async with ydb.aio.SessionPool(driver, 1) as pool:
124+
125+
async def check_transaction(s: ydb.aio.table.Session):
126+
async with s.transaction(allow_split_transactions=False) as tx:
127+
await tx.execute(
128+
"INSERT INTO %s (id) VALUES (1)" % table_name, commit_tx=True
129+
)
130+
131+
with pytest.raises(RuntimeError):
132+
await tx.execute("INSERT INTO %s (id) VALUES (2)" % table_name)
133+
134+
await tx.commit()
135+
136+
async with s.transaction() as tx:
137+
rs = await tx.execute("SELECT COUNT(*) as cnt FROM %s" % table_name)
138+
assert rs[0].rows[0].cnt == 1
139+
140+
await pool.retry_operation(check_transaction)
141+
142+
121143
@pytest.mark.asyncio
122144
async def test_split_transactions_allow_split(driver, table_name):
123145
async with ydb.aio.SessionPool(driver, 1) as pool:

tests/aio/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ async def test_types(driver, database, value, ydb_type):
6262
@pytest.mark.parametrize(
6363
"value,ydb_type,result_value",
6464
[
65-
# FIXME: TypeError: 'datetime.date'/'datetime.datetime' object cannot be interpreted as an integer
66-
# (test_today, 'Date', test_today),
65+
# FIXME: TypeError: 'datetime.datetime' object cannot be interpreted as an integer
6766
# (test_dt_today, "Datetime", test_dt_today),
67+
(test_today, "Date", test_today),
6868
(365, "Date", date(1971, 1, 1)),
6969
(3600 * 24 * 365, "Datetime", datetime(1971, 1, 1, 0, 0)),
7070
(test_td, "Interval", test_td),

tests/table/table_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import ydb
2+
3+
4+
class TestTable:
5+
def test_create_table_with_not_null_primary_key_by_api(self, driver_sync, database):
6+
table_path = database + "/test_table"
7+
8+
def create_table(session: ydb.Session):
9+
try:
10+
session.drop_table(table_path)
11+
except ydb.issues.SchemeError:
12+
pass
13+
14+
description = (
15+
ydb.TableDescription()
16+
.with_primary_keys("key1")
17+
.with_columns(
18+
ydb.Column("key1", ydb.PrimitiveType.Uint64),
19+
ydb.Column("value", ydb.OptionalType(ydb.PrimitiveType.Utf8)),
20+
)
21+
)
22+
23+
session.create_table(table_path, description)
24+
25+
with ydb.SessionPool(driver_sync) as pool:
26+
pool.retry_operation_sync(create_table)
27+
28+
res = driver_sync.scheme_client.describe_path(table_path)
29+
assert res.type == ydb.scheme.SchemeEntryType.TABLE

tests/table/test_tx.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,27 @@ def check_transaction(s: ydb.table.Session):
112112
pool.retry_operation_sync(check_transaction)
113113

114114

115+
def test_split_transactions_deny_split_flag_commit(driver_sync, table_name):
116+
with ydb.SessionPool(driver_sync, 1) as pool:
117+
118+
def check_transaction(s: ydb.table.Session):
119+
with s.transaction(allow_split_transactions=False) as tx:
120+
tx.execute(
121+
"INSERT INTO %s (id) VALUES (1)" % table_name, commit_tx=True
122+
)
123+
124+
with pytest.raises(RuntimeError):
125+
tx.execute("INSERT INTO %s (id) VALUES (2)" % table_name)
126+
127+
tx.commit()
128+
129+
with s.transaction() as tx:
130+
rs = tx.execute("SELECT COUNT(*) as cnt FROM %s" % table_name)
131+
assert rs[0].rows[0].cnt == 1
132+
133+
pool.retry_operation_sync(check_transaction)
134+
135+
115136
def test_split_transactions_allow_split(driver_sync, table_name):
116137
with ydb.SessionPool(driver_sync, 1) as pool:
117138

ydb/_session_impl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ def bulk_upsert_request_factory(table, rows, column_types):
407407

408408
def wrap_read_table_response(response):
409409
issues._process_response(response)
410-
return convert.ResultSet.from_message(response.result.result_set)
410+
snapshot = response.snapshot if response.HasField("snapshot") else None
411+
return convert.ResultSet.from_message(response.result.result_set, snapshot=snapshot)
411412

412413

413414
class SessionState(object):

ydb/aio/table.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ async def execute(
194194
self, query, parameters=None, commit_tx=False, settings=None
195195
): # pylint: disable=W0236
196196

197-
self._check_split()
198-
199197
return await super().execute(query, parameters, commit_tx, settings)
200198

201199
async def commit(self, settings=None): # pylint: disable=W0236

0 commit comments

Comments
 (0)