Unverified 提交 24e0ae0c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1008 from katzyn/enum

Fix Column.validateConvertUpdateSequence() for ENUM data type
...@@ -21,6 +21,10 @@ Change Log ...@@ -21,6 +21,10 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1006: "Empty enums are not allowed" in 1.4.197 (mode=MYSQL)
</li>
<li>PR #1007: Copy also SRID in ValueGeometry.getGeometry()
</li>
<li>PR #1004: Preserve type names in more places especially for UUID <li>PR #1004: Preserve type names in more places especially for UUID
</li> </li>
<li>Issue #1000: Regression in INFORMATION_SCHEMA.CONSTRAINTS.CONSTRAINT_TYPE content <li>Issue #1000: Regression in INFORMATION_SCHEMA.CONSTRAINTS.CONSTRAINT_TYPE content
...@@ -401,7 +405,7 @@ Change Log ...@@ -401,7 +405,7 @@ Change Log
</li> </li>
<li>PR #743: Change REGEXP_REPLACE mode for MariaDB and PostgreSQL <li>PR #743: Change REGEXP_REPLACE mode for MariaDB and PostgreSQL
</li> </li>
<li>Issue#646 NPE in CREATE VIEW WITH RECURSIVE & NON_RECURSIVE CTE <li>Issue#646 NPE in CREATE VIEW WITH RECURSIVE &amp; NON_RECURSIVE CTE
</li> </li>
<li>PR #738: Copy javadoc to *BackwardsCompat to fix building of documentation <li>PR #738: Copy javadoc to *BackwardsCompat to fix building of documentation
</li> </li>
...@@ -708,7 +712,7 @@ changed from Types.OTHER (1111) to Types.TIMESTAMP_WITH_TIMEZONE (2014) ...@@ -708,7 +712,7 @@ changed from Types.OTHER (1111) to Types.TIMESTAMP_WITH_TIMEZONE (2014)
</li> </li>
<li>Issue #266: Spatial index not updating, fixed by merging PR #267 <li>Issue #266: Spatial index not updating, fixed by merging PR #267
</li> </li>
<li>PR #302: add support for "with"-subqueries into "join" & "sub-query" statements <li>PR #302: add support for "with"-subqueries into "join" &amp; "sub-query" statements
</li> </li>
<li>Issue #299: Nested derived tables did not always work as expected. <li>Issue #299: Nested derived tables did not always work as expected.
</li> </li>
......
...@@ -334,11 +334,12 @@ public class Column { ...@@ -334,11 +334,12 @@ public class Column {
synchronized (this) { synchronized (this) {
localDefaultExpression = defaultExpression; localDefaultExpression = defaultExpression;
} }
Mode mode = session.getDatabase().getMode();
if (value == null) { if (value == null) {
if (localDefaultExpression == null) { if (localDefaultExpression == null) {
value = ValueNull.INSTANCE; value = ValueNull.INSTANCE;
} else { } else {
value = localDefaultExpression.getValue(session).convertTo(type); value = convert(localDefaultExpression.getValue(session), mode);
if (!localDefaultExpression.isConstant()) { if (!localDefaultExpression.isConstant()) {
session.getGeneratedKeys().add(this); session.getGeneratedKeys().add(this);
} }
...@@ -347,10 +348,9 @@ public class Column { ...@@ -347,10 +348,9 @@ public class Column {
} }
} }
} }
Mode mode = session.getDatabase().getMode();
if (value == ValueNull.INSTANCE) { if (value == ValueNull.INSTANCE) {
if (convertNullToDefault) { if (convertNullToDefault) {
value = localDefaultExpression.getValue(session).convertTo(type); value = convert(localDefaultExpression.getValue(session), mode);
if (!localDefaultExpression.isConstant()) { if (!localDefaultExpression.isConstant()) {
session.getGeneratedKeys().add(this); session.getGeneratedKeys().add(this);
} }
......
...@@ -162,3 +162,26 @@ drop table card; ...@@ -162,3 +162,26 @@ drop table card;
drop type CARD_SUIT; drop type CARD_SUIT;
> ok > ok
CREATE TABLE TEST(ID INT, E1 ENUM('A', 'B') DEFAULT 'A', E2 ENUM('C', 'D') DEFAULT 'C' ON UPDATE 'D');
> ok
INSERT INTO TEST(ID) VALUES (1);
> update count: 1
SELECT * FROM TEST;
> ID E1 E2
> -- -- --
> 1 A C
> rows: 1
UPDATE TEST SET E1 = 'B';
> update count: 1
SELECT * FROM TEST;
> ID E1 E2
> -- -- --
> 1 B D
> rows: 1
DROP TABLE TEST;
> ok
...@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al ...@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al
opti excessively opti excessively
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
geometries
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论