libtabula

Check-in [e32649510e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed the quoted NULL value problem. The code wasn't checking for null values explicitly when building query strings, it was only checking the attributes of the data type. That is, it might ask something like, "Should sql_text_null be quoted", get "yes", and quote the value when building SQL query strings even when the value is a SQL NULL, and thus needs to go literally into the generated SQL.

MySQL++ must have gotten away without such code by playing some kind of game with the field type. This is a better way to do it.

Incidentally, this marks the first version of this branch that runs dtest to completion without diffs! A bit of cleanup, and we can merge it back into the trunk!

Timelines: family | ancestors | descendants | both | mysql-type-info
Files: files | file ages | folders
SHA1: e32649510e044da99bab216c0448f8dbcae76fc3
User & Date: etr 2015-08-13 21:52:53
Context
2015-08-14
03:43
Fixed an operator precedence complaint in the new field type matching code noticed by Clang. check-in: f8610afda3 user: tangent tags: mysql-type-info
2015-08-13
21:52
Fixed the quoted NULL value problem. The code wasn't checking for null values explicitly when building query strings, it was only checking the attributes of the data type. That is, it might ask something like, "Should sql_text_null be quoted", get "yes", and quote the value when building SQL query strings even when the value is a SQL NULL, and thus needs to go literally into the generated SQL.

MySQL++ must have gotten away without such code by playing some kind of game with the field type. This is a better way to do it.

Incidentally, this marks the first version of this branch that runs dtest to completion without diffs! A bit of cleanup, and we can merge it back into the trunk! check-in: e32649510e user: etr tags: mysql-type-info

2015-08-12
21:55
Merged trunk Wishlist changes again, and removed the type_info item from the DB independence section in anticipation of merging this branch into the trunk, since that's what this branch is addressing. check-in: e039e01875 user: etr tags: mysql-type-info
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sql_buffer.cpp.

57
58
59
60
61
62
63







64
65
66
67
68
69
70
SQLBuffer::quote_q() const
{
	if ((type_.c_type() == typeid(libtabula::sql_datetime)) &&
			data_ && (length_ >= 5) && (memcmp(data_, "NOW()", 5) == 0)) {
		// The default DATETIME value is special-cased as a call to the
		// SQL NOW() function, which must not be quoted.
		return false;







	}
	else {
		// Normal case: we can infer the need to quote from the type.
		return type_.quote_q();
	}
}








>
>
>
>
>
>
>







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
SQLBuffer::quote_q() const
{
	if ((type_.c_type() == typeid(libtabula::sql_datetime)) &&
			data_ && (length_ >= 5) && (memcmp(data_, "NOW()", 5) == 0)) {
		// The default DATETIME value is special-cased as a call to the
		// SQL NOW() function, which must not be quoted.
		return false;
	}
	else if (is_null_) {
		// The value is null, which is a separate thing from the type
		// being null-able, so we have to check for it up here.  If
		// you try to push this check down into FieldType::is_null(),
		// something like "sql_int_null x = 5" would be quoted.
		return false;
	}
	else {
		// Normal case: we can infer the need to quote from the type.
		return type_.quote_q();
	}
}