forked from mariadb-corporation/mariadb-connector-j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MariaDbDatabaseMetaDataTest.java
40 lines (30 loc) · 1.73 KB
/
MariaDbDatabaseMetaDataTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.mariadb.jdbc;
import com.fasterxml.jackson.databind.deser.Deserializers;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.sql.*;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import static org.junit.Assert.*;
public class MariaDbDatabaseMetaDataTest extends BaseTest {
@Test
public void testColumnTypeClauseTinyInt1IsBitTrue() throws Exception {
MariaDbConnection connection = (MariaDbConnection)setConnection();
MariaDbDatabaseMetaData dbMetaData = new MariaDbDatabaseMetaData(connection, "", "");
String result = dbMetaData.columnTypeClause(connection.getProtocol().getDataTypeMappingFlags(),"column_name");
assertEquals(" IF(column_name = 'tinyint(1)', 'BIT', UCASE(IF( column_name LIKE '%(%)%', CONCAT("
+ "SUBSTRING( column_name,1, LOCATE('(',column_name) - 1 ), "
+ "SUBSTRING(column_name,1+locate(')',column_name))), column_name)))", result);
}
@Test
public void testColumnTypeClauseTinyInt1IsBitFalse() throws Exception {
Properties props = new Properties();
props.setProperty("tinyInt1isBit", "false");
MariaDbConnection connection = (MariaDbConnection)openNewConnection(connUri, props);
MariaDbDatabaseMetaData dbMetaData = new MariaDbDatabaseMetaData(connection, "", "");
String result = dbMetaData.columnTypeClause(connection.getProtocol().getDataTypeMappingFlags(),"column_name");
assertEquals(" UCASE(IF( column_name LIKE '%(%)%', CONCAT(SUBSTRING( column_name,1, LOCATE('(',column_name) - 1 ), "
+ "SUBSTRING(column_name,1+locate(')',column_name))), column_name))", result);
}
}