• R/O
  • SSH

execsql: コミット

Default repository for execsql.py


コミットメタ情報

リビジョン4fba19b94c45711e2806c34f057e0af14b806a0a (tree)
日時2020-11-09 03:05:43
作者rdnielsen
コミッターrdnielsen

ログメッセージ

Corrected evaluation of integers with leading zeroes as numeric types.

変更サマリ

差分

diff -r f7aca7a15590 -r 4fba19b94c45 doc/source/metacommands.rst
--- a/doc/source/metacommands.rst Sun Nov 01 12:24:32 2020 -0800
+++ b/doc/source/metacommands.rst Sun Nov 08 10:05:43 2020 -0800
@@ -223,7 +223,8 @@
223223 :ref:`IMPORT <import>` and :ref:`COPY <copy>` metacommands always commit
224224 the changes they make, unless :ref:`AUTOCOMMIT <autocommit>` is OFF,
225225 so if IMPORT or COPY metacommands are used inside a batch,
226-any preceding SQL statements in the batch will also be committed.
226+any preceding SQL statements in the batch will also be committed unless
227+AUTOCOMMIT is OFF.
227228
228229 When the END BATCH metacommand is processed by execsql, a commit
229230 command is sent to all databases that have been used inside the
@@ -1101,9 +1102,10 @@
11011102 during the data copying process, no new data will be added to the
11021103 second table.
11031104
1104-The data addition to the target table is always committed. Therefore,
1105-the COPY metacommand generally should not be used within transactions
1106-or :ref:`BATCHes<batch>`.
1105+The data addition to the target table is always committed unless
1106+:ref:`AUTOCOMMIT <autocommit>` is OFF. Therefore, the COPY metacommand
1107+should be used with care within transactions that are managed with
1108+explicit SQL statements or with or :ref:`BATCHes<batch>`.
11071109
11081110
11091111 .. index:: ! COPY QUERY metacommand
@@ -1130,9 +1132,10 @@
11301132 variable <substitution_vars>` and that substitution variable referenced
11311133 in the COPY QUERY metacommand.
11321134
1133-The data addition to the target table is always committed. Therefore,
1134-the COPY QUERY metacommand generally should not be used within transactions
1135-or :ref:`BATCHes<batch>`.
1135+The data addition to the target table is always committed unless
1136+:ref:`AUTOCOMMIT <autocommit>` is OFF. Therefore, the COPY metacommand
1137+should be used with care within transactions that are managed with
1138+explicit SQL statements or with or :ref:`BATCHes<batch>`.
11361139
11371140
11381141
@@ -2837,7 +2840,8 @@
28372840
28382841 Because the data addition to the target table is always committed except
28392842 when :ref:`AUTOCOMMIT <autocommit>` is off,
2840-the IMPORT metacommand generally should not be used within :ref:`BATCHes<batch>`.
2843+the IMPORT metacommand should be used with care within transactions
2844+that are managed with explicit SQL statements or with :ref:`BATCHes<batch>`.
28412845
28422846 .. index::
28432847 single: MySQL
diff -r f7aca7a15590 -r 4fba19b94c45 execsql/execsql.py
--- a/execsql/execsql.py Sun Nov 01 12:24:32 2020 -0800
+++ b/execsql/execsql.py Sun Nov 08 10:05:43 2020 -0800
@@ -27,12 +27,12 @@
2727 #
2828 # ===============================================================================
2929
30-__version__ = "1.80.1"
31-__vdate = "2020-11-01"
30+__version__ = "1.80.2"
31+__vdate = "2020-11-08"
3232
3333 primary_vno = 1
3434 secondary_vno = 80
35-tertiary_vno = 1
35+tertiary_vno = 2
3636
3737 import os
3838 import os.path
@@ -693,18 +693,26 @@
693693
694694 def leading_zero_num(dataval):
695695 # Returns True if the data value is potentially a number but has a leading zero
696- if not isinstance(dataval, stringtypes):
696+ if not isinstance(dataval, str):
697697 return False
698698 if len(dataval) < 2:
699699 return False
700700 if dataval[0] != u'0':
701701 return False
702- try:
703- x = float(dataval[1:])
704- except:
705- return False
706- if x > 1:
702+ dataval = dataval[1:]
703+ if dataval[0] == u'0' and len(dataval) > 1:
704+ try:
705+ x = float(dataval[1:])
706+ except:
707+ return False
707708 return True
709+ else:
710+ try:
711+ x = float(dataval)
712+ except:
713+ return False
714+ if x > 1:
715+ return True
708716 return False
709717
710718 def as_numeric(strval):
@@ -2253,6 +2261,8 @@
22532261 def _from_data(self, data):
22542262 if data is None:
22552263 raise DataTypeError(self.data_type_name, self._CONV_ERR % "NULL")
2264+ if leading_zero_num(data):
2265+ raise DataTypeError(self.data_type_name, self._CONV_ERR % data)
22562266 if type(data) == Decimal:
22572267 self.set_scale_prec(data)
22582268 return data
diff -r f7aca7a15590 -r 4fba19b94c45 setup.py
--- a/setup.py Sun Nov 01 12:24:32 2020 -0800
+++ b/setup.py Sun Nov 08 10:05:43 2020 -0800
@@ -5,7 +5,7 @@
55 long_description = f.read()
66
77 setuptools.setup(name='execsql',
8- version='1.80.1',
8+ version='1.80.2',
99 description="Runs a SQL script against a PostgreSQL, MS-Access, SQLite, MS-SQL-Server, MySQL, MariaDB, Firebird, or Oracle database, or an ODBC DSN. Provides metacommands to import and export data, copy data between databases, conditionally execute SQL and metacommands, and dynamically alter SQL and metacommands with substitution variables. Data can be exported in 18 different formats, including CSV, TSV, ODS, HTML, JSON, LaTeX, and Markdown tables, and using custom templates.",
1010 author='Dreas Nielsen',
1111 author_email='dreas.nielsen@gmail.com',
旧リポジトリブラウザで表示