8000 Release 1.2.0 · FirebirdSQL/python3-lib@fa270b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit fa270b9

Browse files
committed
Release 1.2.0
1 parent cdaa005 commit fa270b9

File tree

9 files changed

+300
-124
lines changed

9 files changed

+300
-124
lines changed

docs/changelog.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
Changelog
33
#########
44

5+
Version 1.2.0
6+
=============
7+
8+
.. module:: firebird.lib.schema
9+
:noindex:
10+
11+
* schema: `Sequence` ALTER SQL uses RESTART instead START keyword.
12+
* schema: Fix index type in `Constraint` and `Table` CREATE SQL.
13+
* schema: Added `insert` SQL for `.Table`.
14+
15+
.. module:: firebird.lib.trace
16+
:noindex:
17+
18+
* trace: Add `TransactionInfo.initial_id`.
19+
* trace: Add `EventCommitRetaining.new_transaction_id` and `EventRollbackRetaining.new_transaction_id`.
20+
* trace: `EventFreeStatement.transaction_id` and `EventCloseCursor.transaction_id` were removed.
21+
* trace: Added events `.EventFunctionStart` and `.EventFunctionFinish`.
22+
* trace: `EventServiceQuery.parameters` was replaced by `EventServiceQuery.sent` and
23+
`EventServiceQuery.received`.
24+
* trace: Added `EventSweepFinish.access`.
25+
* trace: Fixed several unregistered bugs in parser.
26+
527
Version 1.0.1
628
=============
729

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
author = 'Pavel Císař'
2424

2525
# The short X.Y version
26-
version = '1.0.1'
26+
version = '1.2.0'
2727

2828
# The full version, including alpha/beta/rc tags
29-
release = '1.0.1'
29+
release = '1.2.0'
3030

3131

3232
# -- General configuration ---------------------------------------------------

docs/ref-trace.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ EventProcedureFinish
135135
--------------------
136136
.. autoclass:: EventProcedureFinish
137137

138+
EventFunctionStart
139+
------------------
140+
.. autoclass:: EventFunctionStart
141+
142+
EventFunctionFinish
143+
-------------------
144+
.. autoclass:: EventFunctionFinish
145+
138146
EventServiceAttach
139147
------------------
140148
.. autoclass:: EventServiceAttach

firebird/lib/schema.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ def _get_alter_sql(self, **params) -> str:
19781978
value = params.get('value')
19791979
inc = params.get('increment')
19801980
cmd = f'ALTER {self.schema.opt_generator_keyword} {self.get_quoted_name()} ' \
1981-
f'{f"START WITH {value}" if isinstance(value,int) else ""} ' \
1981+
f'{f"RESTART WITH {value}" if isinstance(value,int) else ""} ' \
19821982
f'{f"INCREMENT BY {inc}" if inc else ""}'
19831983
return cmd.strip()
19841984
def _get_drop_sql(self, **params) -> str:
@@ -2830,7 +2830,7 @@ def _get_create_sql(self, **params) -> str:
28302830
i = self.index
28312831
const_def += f" ({','.join(i.segment_names)})"
28322832
if not i.is_sys_object():
2833-
const_def += f'\n USING {i.index_type} INDEX {i.get_quoted_name()}'
2833+
const_def += f'\n USING {i.index_type.value} INDEX {i.get_quoted_name()}'
28342834
elif self.is_fkey():
28352835
const_def += f"FOREIGN KEY ({','.join(self.index.segment_names)})\n "
28362836
p = self.partner_constraint
@@ -2841,7 +2841,7 @@ def _get_create_sql(self, **params) -> str:
28412841
const_def += f'\n ON UPDATE {self.update_rule}'
28422842
i = self.index
28432843
if not i.is_sys_object():
2844-
const_def += f'\n USING {i.index_type} INDEX {i.get_quoted_name()}'
2844+
const_def += f'\n USING {i.index_type.value} INDEX {i.get_quoted_name()}'
28452845
else:
28462846
raise Error(f"Unrecognized constraint type '{self.constraint_type}'")
28472847
return const_def
@@ -2946,7 +2946,7 @@ class Table(SchemaItem):
29462946
29472947
Supported SQL actions:
29482948
- User table: `create` (no_pk=bool, no_unique=bool), `recreate` (no_pk=bool, no_unique=bool),
2949-
`drop`, `comment`
2949+
`drop`, `comment`, `insert (update=bool, returning=list[str], matching=list[str])`
29502950
- System table: `comment`
29512951
"""
29522952
def __init__(self, schema: Schema, attributes: Dict[str, Any]):
@@ -2960,6 +2960,23 @@ def __init__(self, schema: Schema, attributes: Dict[str, Any]):
29602960
self._actions.append('comment')
29612961
if not self.is_sys_object():
29622962
self._actions.extend(['create', 'recreate', 'drop'])
2963+
def _get_insert_sql(self, **params) -> str:
2964+
try:
2965+
self._check_params(params, ['update', 'returning', 'matching'])
2966+
update = params.get('update', False)
2967+
returning = params.get('returning')
2968+
matching = params.get('returning')
2969+
#
2970+
result = f"{'UPDATE OR ' if update else ''}INSERT TABLE {self.get_quoted_name()}"
2971+
result += f" ({','.join(col.get_quoted_name() for col in self.columns)})"
2972+
result += f" VALUES ({','.join('?' for col in self.columns)})"
2973+
if matching:
2974+
result += f" MATCHING ({','.join(matching)})"
2975+
if returning:
2976+
result += f" RETURNING ({','.join(returning)})"
2977+
return result
2978+
except Exception as e:
2979+
raise e
29632980
def _get_create_sql(self, **params) -> str:
29642981
try:
29652982
self._check_params(params, ['no_pk', 'no_unique'])
@@ -3009,7 +3026,7 @@ def _get_create_sql(self, **params) -> str:
30093026
i = pk.index
30103027
pkdef += f"PRIMARY KEY ({','.join(i.segment_names)})"
30113028
if not i.is_sys_object():
3012-
pkdef += f'\n USING {i.index_type} INDEX {i.get_quoted_name()}'
3029+
pkdef += f'\n USING {i.index_type.value} INDEX {i.get_quoted_name()}'
30133030
partdefs.append(pkdef)
30143031
if not no_unique:
30153032
for uq in self.constraints:
@@ -3020,7 +3037,7 @@ def _get_create_sql(self, **params) -> str:
30203037
i = uq.index
30213038
uqdef += f"UNIQUE ({','.join(i.segment_names)})"
30223039
if not i.is_sys_object():
3023-
uqdef += f'\n USING {i.index_type} INDEX {i.get_quoted_name()}'
3040+
uqdef += f'\n USING {i.index_type.value} INDEX {i.get_quoted_name()}'
30243041
partdefs.append(uqdef)
30253042
tabdef += ','.join(partdefs)
30263043
tabdef += '\n)'

0 commit comments

Comments
 (0)
0