While these databases allow implicit casts (at least from int to
string), in MySQL at least the implicit cast can prevent appropriate
index usage (see T216183). So let's have buildStringCast() actually do
the cast.
This also changes the base implementation in Wikimedia\Rdmbs\Database to
explicitly cast. Any other subclasses should check whether this new
version works for them.
Bug: T216247
Change-Id: I98c67c857b35de3191d47ab28810d8eb21ddbbc8
=== Other changes in 1.33 ===
* (T201747) Html::openElement() warns if given an element name with a space
in it.
+* The implementation of buildStringCast() in Wikimedia\Rdbms\Database has
+ changed to explicitly cast. Subclasses relying on the base-class
+ implementation should check whether they need to override it now.
== Compatibility ==
MediaWiki 1.33 requires PHP 7.0.13 or later. Although HHVM 3.18.5 or later is
}
public function buildStringCast( $field ) {
- return $field;
+ // In theory this should work for any standards-compliant
+ // SQL implementation, although it may not be the best way to do it.
+ return "CAST( $field AS CHARACTER )";
}
public function buildIntegerCast( $field ) {
return $old;
}
+
+ public function buildStringCast( $field ) {
+ return "CAST( $field AS NVARCHAR )";
+ }
+
}
/**
!preg_match( '/^SELECT\s+(GET|RELEASE|IS_FREE)_LOCK\(/', $sql );
}
+ public function buildStringCast( $field ) {
+ return "CAST( $field AS BINARY )";
+ }
+
/**
* @param string $field Field or column to cast
* @return string