1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-08-30 22:57:59 -04:00
parent ed911e3de5
commit 5fc4eb41ec
579 changed files with 2460 additions and 1564 deletions

View File

@@ -28,7 +28,7 @@ public class Db_qry_flush implements Db_qry {
public static Db_qry_flush as_(Object obj) {return obj instanceof Db_qry_flush ? (Db_qry_flush)obj : null;}
public static Db_qry_flush cast_(Object obj) {try {return (Db_qry_flush)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Db_qry_flush.class, obj);}}
public static Db_qry_flush cast(Object obj) {try {return (Db_qry_flush)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Db_qry_flush.class, obj);}}
public static Db_qry_flush new_(String... ary) {
Db_qry_flush rv = new Db_qry_flush();
rv.tableNames = ary;

View File

@@ -37,7 +37,7 @@ public class Db_qry_sql implements Db_qry {
return rv;
}
public static Db_qry_sql as_(Object obj) {return obj instanceof Db_qry_sql ? (Db_qry_sql)obj : null;}
public static Db_qry_sql cast_(Object obj) {try {return (Db_qry_sql)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Db_qry_sql.class, obj);}}
public static Db_qry_sql cast(Object obj) {try {return (Db_qry_sql)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Db_qry_sql.class, obj);}}
public static String Gen_sql(Db_qry qry, Object... args) {
byte[] src = Bry_.new_u8(Sql_qry_wtr_.Gen_placeholder_parameters(qry));
int src_len = src.length;
@@ -58,21 +58,21 @@ public class Db_qry_sql implements Db_qry {
if (val == null) {bfr.Add(Bry_null); return;}
Class<?> val_type = val.getClass();
if (Type_adp_.Eq(val_type, Int_.Cls_ref_type))
bfr.Add_int_variable(Int_.cast_(val));
bfr.Add_int_variable(Int_.cast(val));
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type))
bfr.Add_int_fixed(1, Bool_.Xto_int(Bool_.cast_(val))); // NOTE: save boolean to 0 or 1, b/c (a) db may not support bit datatype (sqllite) and (b) avoid i18n issues with "true"/"false"
bfr.Add_int_fixed(1, Bool_.To_int(Bool_.cast(val))); // NOTE: save boolean to 0 or 1, b/c (a) db may not support bit datatype (sqllite) and (b) avoid i18n issues with "true"/"false"
else if (Type_adp_.Eq(val_type, Double_.Cls_ref_type))
bfr.Add_double(Double_.cast_(val));
bfr.Add_double(Double_.cast(val));
else if (Type_adp_.Eq(val_type, Long_.Cls_ref_type))
bfr.Add_long_variable(Long_.cast_(val));
bfr.Add_long_variable(Long_.cast(val));
else if (Type_adp_.Eq(val_type, Float_.Cls_ref_type))
bfr.Add_float(Float_.cast_(val));
bfr.Add_float(Float_.cast(val));
else if (Type_adp_.Eq(val_type, Byte_.Cls_ref_type))
bfr.Add_byte(Byte_.cast_(val));
bfr.Add_byte(Byte_.cast(val));
else if (Type_adp_.Eq(val_type, DateAdp_.Cls_ref_type))
bfr.Add_byte_apos().Add_str(DateAdp_.cast_(val).XtoStr_gplx_long()).Add_byte_apos();
bfr.Add_byte_apos().Add_str(DateAdp_.cast(val).XtoStr_gplx_long()).Add_byte_apos();
else if (Type_adp_.Eq(val_type, Decimal_adp_.Cls_ref_type))
bfr.Add_str(Decimal_adp_.cast_(val).To_str());
bfr.Add_str(Decimal_adp_.cast(val).To_str());
else {
byte[] val_bry = Bry_.new_u8(Object_.Xto_str_strict_or_null(val));
val_bry = Bry_.Replace(val_bry, Byte_ascii.Apos_bry, Bry_escape_apos);

View File

@@ -22,7 +22,7 @@ public class Db_qry_sql_tst {
@Test public void Insert() {
fxt.Test_qry
( Db_qry_insert.new_("tbl", "k1", "k2", "k3", "k4", "k5", "k6", "k7", "k8", "k9")
, Object_.Ary(123, Bool_.Y, 1.23d, 123L, 123f, Byte_ascii.Num_1, "123", DateAdp_.parse_iso8561("1981-04-05T14:30:30"), Decimal_adp_.parse_("1.23"))
, Object_.Ary(123, Bool_.Y, 1.23d, 123L, 123f, Byte_ascii.Num_1, "123", DateAdp_.parse_iso8561("1981-04-05T14:30:30"), Decimal_adp_.parse("1.23"))
, "INSERT INTO tbl (k1, k2, k3, k4, k5, k6, k7, k8, k9) VALUES (123, 1, 1.23, 123, 123, 1, '123', '1981-04-05 14:30:30.000', 1.23)"
);
}