mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 10:22:20 +08:00
7.0 became 6.3, so change API versions accordingly
This commit is contained in:
parent
7b87cc3f88
commit
ffc36dcf45
@ -253,9 +253,9 @@ def transactional(*tr_args, **tr_kwargs):
|
|||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
# We can't throw this from the decorator, as when a user runs
|
# We can't throw this from the decorator, as when a user runs
|
||||||
# >>> import fdb ; fdb.api_version(700)
|
# >>> import fdb ; fdb.api_version(630)
|
||||||
# the code above uses @transactional before the API version is set
|
# the code above uses @transactional before the API version is set
|
||||||
if fdb.get_api_version() >= 700 and inspect.isgeneratorfunction(func):
|
if fdb.get_api_version() >= 630 and inspect.isgeneratorfunction(func):
|
||||||
raise ValueError("Generators can not be wrapped with fdb.transactional")
|
raise ValueError("Generators can not be wrapped with fdb.transactional")
|
||||||
|
|
||||||
if isinstance(args[index], TransactionRead):
|
if isinstance(args[index], TransactionRead):
|
||||||
@ -273,7 +273,7 @@ def transactional(*tr_args, **tr_kwargs):
|
|||||||
ret = None
|
ret = None
|
||||||
try:
|
try:
|
||||||
ret = func(*largs, **kwargs)
|
ret = func(*largs, **kwargs)
|
||||||
if fdb.get_api_version() >= 700 and inspect.isgenerator(ret):
|
if fdb.get_api_version() >= 630 and inspect.isgenerator(ret):
|
||||||
raise ValueError("Generators can not be wrapped with fdb.transactional")
|
raise ValueError("Generators can not be wrapped with fdb.transactional")
|
||||||
tr.commit().wait()
|
tr.commit().wait()
|
||||||
committed = True
|
committed = True
|
||||||
|
@ -132,9 +132,9 @@ def test_fdb_transactional_generator(db):
|
|||||||
@fdb.transactional
|
@fdb.transactional
|
||||||
def function_that_yields(tr):
|
def function_that_yields(tr):
|
||||||
yield 0
|
yield 0
|
||||||
assert fdb.get_api_version() < 700, "Pre-7.0, a decorators may wrap a function that yield"
|
assert fdb.get_api_version() < 630, "Pre-6.3, a decorators may wrap a function that yield"
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
assert fdb.get_api_version() >= 700, "Post-7.0, a decorator should throw if wrapped function yields"
|
assert fdb.get_api_version() >= 630, "Post-6.3, a decorator should throw if wrapped function yields"
|
||||||
|
|
||||||
|
|
||||||
def test_fdb_transactional_returns_generator(db):
|
def test_fdb_transactional_returns_generator(db):
|
||||||
@ -145,9 +145,9 @@ def test_fdb_transactional_returns_generator(db):
|
|||||||
def function_that_returns(tr):
|
def function_that_returns(tr):
|
||||||
return function_that_yields(tr)
|
return function_that_yields(tr)
|
||||||
function_that_returns()
|
function_that_returns()
|
||||||
assert fdb.get_api_version() < 700, "Pre-7.0, returning a generator is allowed"
|
assert fdb.get_api_version() < 630, "Pre-6.3, returning a generator is allowed"
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
assert fdb.get_api_version() >= 700, "Post-7.0, returning a generator should throw"
|
assert fdb.get_api_version() >= 630, "Post-6.3, returning a generator should throw"
|
||||||
|
|
||||||
|
|
||||||
def test_db_options(db):
|
def test_db_options(db):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user