+ /**
+ * Given a meta type, return the appropriate alias if applicable
+ *
+ * @since 3.7.0
+ *
+ * @param string $type MySQL type to cast meta_value
+ * @return string MySQL type
+ */
+ function get_cast_for_type( $type = '' ) {
+ if ( empty( $type ) )
+ return 'CHAR';
+
+ $meta_type = strtoupper( $type );
+
+ if ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED', 'NUMERIC' ) ) )
+ return 'CHAR';
+
+ if ( 'NUMERIC' == $meta_type )
+ $meta_type = 'SIGNED';
+
+ return $meta_type;
+ }
+