return $this->__call( __FUNCTION__, func_get_args() );
}
+ public function buildIntegerCast( $field ) {
+ return $this->__call( __FUNCTION__, func_get_args() );
+ }
+
public function databasesAreIndependent() {
return $this->__call( __FUNCTION__, func_get_args() );
}
return $field;
}
+ public function buildIntegerCast( $field ) {
+ return 'CAST( ' . $field . ' AS INTEGER )';
+ }
+
public function databasesAreIndependent() {
return false;
}
return parent::isTransactableQuery( $sql ) &&
!preg_match( '/^SELECT\s+(GET|RELEASE|IS_FREE)_LOCK\(/', $sql );
}
+
+ /**
+ * @param string $field Field or column to cast
+ * @return string
+ */
+ public function buildIntegerCast( $field ) {
+ return 'CAST( ' . $field . ' AS SIGNED )';
+ }
+
}
class_alias( DatabaseMysqlBase::class, 'DatabaseMysqlBase' );
*/
public function buildStringCast( $field );
+ /**
+ * @param string $field Field or column to cast
+ * @return string
+ * @since 1.31
+ */
+ public function buildIntegerCast( $field );
+
/**
* Returns true if DBs are assumed to be on potentially different servers
*
];
}
+
+ /**
+ * @covers \Wikimedia\Rdbms\DatabaseMysqlBase::buildIntegerCast
+ */
+ public function testBuildIntegerCast() {
+ $db = new FakeDatabaseMysqlBase();
+ $output = $db->buildIntegerCast( 'fieldName' );
+ $this->assertSame( 'CAST( fieldName AS SIGNED )', $output );
+ }
+
}
$this->database->buildSubstring( 'foo', $start, $length );
}
+ /**
+ * @covers \Wikimedia\Rdbms\Database::buildIntegerCast
+ */
+ public function testBuildIntegerCast() {
+ $output = $this->database->buildIntegerCast( 'fieldName' );
+ $this->assertSame( 'CAST( fieldName AS INTEGER )', $output );
+ }
+
}