リビジョン | 4fba19b94c45711e2806c34f057e0af14b806a0a (tree) |
---|---|
日時 | 2020-11-09 03:05:43 |
作者 | rdnielsen |
コミッター | rdnielsen |
Corrected evaluation of integers with leading zeroes as numeric types.
@@ -223,7 +223,8 @@ | ||
223 | 223 | :ref:`IMPORT <import>` and :ref:`COPY <copy>` metacommands always commit |
224 | 224 | the changes they make, unless :ref:`AUTOCOMMIT <autocommit>` is OFF, |
225 | 225 | 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. | |
227 | 228 | |
228 | 229 | When the END BATCH metacommand is processed by execsql, a commit |
229 | 230 | command is sent to all databases that have been used inside the |
@@ -1101,9 +1102,10 @@ | ||
1101 | 1102 | during the data copying process, no new data will be added to the |
1102 | 1103 | second table. |
1103 | 1104 | |
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>`. | |
1107 | 1109 | |
1108 | 1110 | |
1109 | 1111 | .. index:: ! COPY QUERY metacommand |
@@ -1130,9 +1132,10 @@ | ||
1130 | 1132 | variable <substitution_vars>` and that substitution variable referenced |
1131 | 1133 | in the COPY QUERY metacommand. |
1132 | 1134 | |
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>`. | |
1136 | 1139 | |
1137 | 1140 | |
1138 | 1141 |
@@ -2837,7 +2840,8 @@ | ||
2837 | 2840 | |
2838 | 2841 | Because the data addition to the target table is always committed except |
2839 | 2842 | 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>`. | |
2841 | 2845 | |
2842 | 2846 | .. index:: |
2843 | 2847 | single: MySQL |
@@ -27,12 +27,12 @@ | ||
27 | 27 | # |
28 | 28 | # =============================================================================== |
29 | 29 | |
30 | -__version__ = "1.80.1" | |
31 | -__vdate = "2020-11-01" | |
30 | +__version__ = "1.80.2" | |
31 | +__vdate = "2020-11-08" | |
32 | 32 | |
33 | 33 | primary_vno = 1 |
34 | 34 | secondary_vno = 80 |
35 | -tertiary_vno = 1 | |
35 | +tertiary_vno = 2 | |
36 | 36 | |
37 | 37 | import os |
38 | 38 | import os.path |
@@ -693,18 +693,26 @@ | ||
693 | 693 | |
694 | 694 | def leading_zero_num(dataval): |
695 | 695 | # 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): | |
697 | 697 | return False |
698 | 698 | if len(dataval) < 2: |
699 | 699 | return False |
700 | 700 | if dataval[0] != u'0': |
701 | 701 | 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 | |
707 | 708 | return True |
709 | + else: | |
710 | + try: | |
711 | + x = float(dataval) | |
712 | + except: | |
713 | + return False | |
714 | + if x > 1: | |
715 | + return True | |
708 | 716 | return False |
709 | 717 | |
710 | 718 | def as_numeric(strval): |
@@ -2253,6 +2261,8 @@ | ||
2253 | 2261 | def _from_data(self, data): |
2254 | 2262 | if data is None: |
2255 | 2263 | 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) | |
2256 | 2266 | if type(data) == Decimal: |
2257 | 2267 | self.set_scale_prec(data) |
2258 | 2268 | return data |
@@ -5,7 +5,7 @@ | ||
5 | 5 | long_description = f.read() |
6 | 6 | |
7 | 7 | setuptools.setup(name='execsql', |
8 | - version='1.80.1', | |
8 | + version='1.80.2', | |
9 | 9 | 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.", |
10 | 10 | author='Dreas Nielsen', |
11 | 11 | author_email='dreas.nielsen@gmail.com', |