use of com.github.drinkjava2.jdialects.Dialect in project jDialects by drinkjava2.
the class DialectTest method testPagination.
@Test
public void testPagination() {
Dialect[] dialects = Dialect.values();
for (Dialect dialect : dialects) {
System.out.println("=========" + dialect + "==========");
String result = "";
try {
System.out.println(dialect);
result = dialect.paginate(1, 10, sql1);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
try {
result = dialect.paginate(3, 10, sql1);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
try {
result = dialect.paginate(1, 10, sql2);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
try {
result = dialect.paginate(3, 10, sql2);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
}
}
use of com.github.drinkjava2.jdialects.Dialect in project jDialects by drinkjava2.
the class DialectTest method testDDLTypeMapping7.
@Test
public void testDDLTypeMapping7() {
Dialect d = Dialect.MySQL5InnoDBDialect;
String ddl = //
"create table ddl_test(" + "f1 " + //
d.BIGINT() + ",f2 " + //
d.BINARY(5) + ",f3 " + //
d.BIT() + ",f4 " + //
d.BLOB() + ",f5 " + //
d.BOOLEAN() + ",f6 " + //
d.CHAR() + ",f7 " + //
d.CLOB() + ",f8 " + //
d.DATE() + // + ",f9 " + d.DECIMAL(3,5) //
",f10 " + //
d.DOUBLE() + ",f11 " + //
d.FLOAT() + ",f12 " + //
d.INTEGER() + // + ",f13 " + d.JAVA_OBJECT() //
",f14 " + //
d.LONGNVARCHAR(10) + ",f15 " + //
d.LONGVARBINARY() + ",f16 " + //
d.LONGVARCHAR() + ",f17 " + //
d.NCHAR(5) + ",f18 " + //
d.NCLOB() + ",f19 " + //
d.NUMERIC(6, 4) + ",f20 " + //
d.NVARCHAR(6) + // + ",f21 " + d.OTHER() //
",f22 " + //
d.REAL() + ",f23 " + //
d.SMALLINT() + ",f24 " + //
d.TIME() + ",f25 " + //
d.TIMESTAMP() + ",f26 " + //
d.TINYINT() + ",f27 " + //
d.VARBINARY() + ",f28 " + //
d.VARCHAR(10) + ")" + d.engine(" DEFAULT CHARSET=utf8");
System.out.println(ddl);
d = Dialect.Oracle10gDialect;
ddl = //
"create table ddl_test(" + "f1 " + //
d.BIGINT() + ",f2 " + //
d.BINARY(5) + ",f3 " + //
d.BIT() + ",f4 " + //
d.BLOB() + ",f5 " + //
d.BOOLEAN() + ",f6 " + //
d.CHAR() + ",f7 " + //
d.CLOB() + ",f8 " + //
d.DATE() + ",f9 " + //
d.DECIMAL(3, 5) + ",f10 " + //
d.DOUBLE() + ",f11 " + //
d.FLOAT() + ",f12 " + //
d.INTEGER() + // + ",f13 " + d.JAVA_OBJECT() //
",f14 " + //
d.LONGNVARCHAR(10) + ",f15 " + //
d.LONGVARBINARY() + ",f16 " + //
d.LONGVARCHAR() + ",f17 " + //
d.NCHAR(5) + ",f18 " + //
d.NCLOB() + ",f19 " + //
d.NUMERIC(6, 4) + ",f20 " + //
d.NVARCHAR(6) + // + ",f21 " + d.OTHER() //
",f22 " + //
d.REAL() + ",f23 " + //
d.SMALLINT() + ",f24 " + //
d.TIME() + ",f25 " + //
d.TIMESTAMP() + ",f26 " + //
d.TINYINT() + ",f27 " + //
d.VARBINARY() + ",f28 " + //
d.VARCHAR(10) + ")" + d.engine();
System.out.println(ddl);
}
use of com.github.drinkjava2.jdialects.Dialect in project jDialects by drinkjava2.
the class DialectTest method testPagination2.
@Test
public void testPagination2() {
Dialect[] dialects = Dialect.values();
for (Dialect dialect : dialects) {
System.out.println("=========" + dialect + "==========");
String result = "";
try {
result = dialect.paginate(1, 10, sql3);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
Assert.assertTrue(StrUtils.isEmpty(result) || 1 == StrUtils.countMatches(result, '?'));
try {
result = dialect.paginate(3, 10, sql4);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
Assert.assertTrue(StrUtils.isEmpty(result) || 1 == StrUtils.countMatches(result, '?'));
try {
result = dialect.paginate(1, 10, sql3);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
Assert.assertTrue(StrUtils.isEmpty(result) || 1 == StrUtils.countMatches(result, '?'));
try {
result = dialect.paginate(3, 10, sql4);
System.out.println(result);
} catch (DialectException e) {
System.out.println("Error:" + e.getMessage());
}
Assert.assertFalse(result.contains("$"));
Assert.assertTrue(StrUtils.isEmpty(result) || 1 == StrUtils.countMatches(result, '?'));
}
}
use of com.github.drinkjava2.jdialects.Dialect in project jDialects by drinkjava2.
the class TableTest method printAllDialectsDDLs.
private static void printAllDialectsDDLs(Table... tables) {
Dialect[] diaList = Dialect.values();
for (Dialect dialect : diaList) {
System.out.println("======" + dialect + "=====");
try {
String[] ddl = dialect.toCreateDDL(tables);
printDDLs(ddl);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception found: " + e.getMessage());
}
}
}
use of com.github.drinkjava2.jdialects.Dialect in project jDialects by drinkjava2.
the class SortedUUIDGenerator method getNextID.
@Override
public Object getNextID(NormalJdbcTool jdbc, Dialect dialect, Type dataType) {
String s = "" + AutoIdGenerator.INSTANCE.getNextID(jdbc, dialect, dataType);
if (s.length() > (sortedLength - 1))
throw new DialectException("SortedLength should set bigger than auto generated ID length");
StringBuilder sb = new StringBuilder("1");
for (int i = 1; i < sortedLength - s.length(); i++) sb.append("0");
sb.append(s);
sb.append(UUIDAnyGenerator.getAnyLengthRadix36UUID(uuidLength));
return sb.toString();
}
Aggregations