1 2 12 package com.versant.core.jdbc.sql; 13 14 import com.versant.core.jdbc.metadata.*; 15 import com.versant.core.jdbc.sql.exp.SqlExp; 16 import com.versant.core.util.CharBuf; 17 18 import java.io.PrintWriter ; 19 20 import com.versant.core.util.CharBuf; 21 22 25 public class InstantDbSqlDriver extends SqlDriver { 26 27 30 public String getName() { 31 return "instantdb"; 32 } 33 34 38 public boolean isAnsiJoinSyntax() { 39 return true; 40 } 41 42 45 public boolean isNullForeignKeyOk() { 46 return true; 47 } 48 49 53 public JdbcNameGenerator createJdbcNameGenerator() { 54 DefaultJdbcNameGenerator n = createDefaultJdbcNameGenerator(); 55 n.setMaxColumnNameLength(31); 56 n.setMaxTableNameLength(31); 57 n.setMaxConstraintNameLength(31); 58 n.setMaxIndexNameLength(31); 59 return n; 60 } 61 62 66 protected void appendCreateColumnNulls(JdbcTable t, JdbcColumn c, 67 CharBuf s) { 68 if (c.nulls) s.append(" null"); 69 } 70 71 74 protected void appendPrimaryKeyConstraint(JdbcTable t, CharBuf s) { 75 s.append("constraint "); 76 s.append(t.pkConstraintName); 77 s.append(" primary key ("); 78 appendColumnNameList(t.pk, s); 79 s.append(')'); 80 } 81 82 85 protected void appendRefConstraint(CharBuf s, JdbcConstraint c) { 86 } 87 88 91 protected void print(PrintWriter out, String sql) { 92 out.print(sql); 93 out.println(";"); 94 out.println(); 95 } 96 97 100 public void appendSqlFrom(JdbcTable table, String alias, 101 CharBuf s) { 102 s.append(table.name); 103 if (alias != null) { 104 s.append(" AS "); 105 s.append(alias); 106 } 107 } 108 109 115 public void appendSqlFromJoin(JdbcTable table, String alias, SqlExp exp, 116 boolean outer, CharBuf s) { 117 if (outer) s.append(" LEFT JOIN "); 118 else s.append(" JOIN "); 119 s.append(table.name); 120 if (alias != null) { 121 s.append(" AS "); 122 s.append(alias); 123 } 124 if (exp != null) { 125 s.append(" ON ("); 126 exp.appendSQL(this, s, null); 127 s.append(')'); 128 } 129 } 130 131 } 132 | Popular Tags |