mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.5.1
This commit is contained in:
@@ -73,8 +73,8 @@ public class Db_conn {
|
||||
Gfo_usr_dlg_.I.Plog_many("", "", "done:" + msg);
|
||||
return rv;
|
||||
}
|
||||
public int Exec_qry(Db_qry qry) {return Int_.cast_(engine.Exec_as_obj(qry));}
|
||||
public DataRdr Exec_qry_as_rdr(Db_qry qry) {return DataRdr_.cast_(engine.Exec_as_obj(qry));}
|
||||
public int Exec_qry(Db_qry qry) {return Int_.cast(engine.Exec_as_obj(qry));}
|
||||
public DataRdr Exec_qry_as_rdr(Db_qry qry) {return DataRdr_.cast(engine.Exec_as_obj(qry));}
|
||||
public int Exec_sql_args(String sql, Object... args) {return this.Exec_qry(Db_qry_sql.dml_(String_.Format(sql, args)));}
|
||||
public DataRdr Exec_sql_as_rdr(String sql) {return this.Exec_qry_as_rdr(Db_qry_sql.rdr_(sql));}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Db_conn_ {
|
||||
if (rdr.MoveNextPeer()) {
|
||||
Object rv_obj = rdr.ReadAt(0);
|
||||
if (rv_obj != null) // Max(fil_id) will be NULL if tbl is empty
|
||||
rv = Int_.cast_or_(rv_obj, or);
|
||||
rv = Int_.cast_or(rv_obj, or);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.dbs.engines.mysql.*; import gplx.dbs.engines.postgres.*;
|
||||
public class Db_conn_info_ {
|
||||
public static final Db_conn_info Null = Noop_conn_info.I;
|
||||
public static final Db_conn_info Test = Mysql_conn_info.new_("127.0.0.1", "unit_tests", "root", "mysql7760");
|
||||
public static Db_conn_info parse_(String raw) {return Db_conn_info_pool._.Parse(raw);}
|
||||
public static Db_conn_info parse(String raw) {return Db_conn_info_pool._.Parse(raw);}
|
||||
public static Db_conn_info sqlite_(Io_url url) {return Sqlite_conn_info.load_(url);}
|
||||
public static Db_conn_info tdb_(Io_url url) {return Tdb_conn_info.new_(url);}
|
||||
public static Db_conn_info mem_(String db) {return Db_conn_info__mem.new_(db);}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Db_conn_pool {
|
||||
public void Del(Db_conn_info url) {conn_hash.Del(url.Xto_api());}
|
||||
public Db_conn Get_or_new__mem(String db) {return Get_or_new(Db_conn_info__mem.new_(db));}
|
||||
public Db_conn Get_or_new__sqlite(Io_url url) {return Get_or_new(Db_conn_info_.sqlite_(url));}
|
||||
public Db_conn Get_or_new(String s) {return Get_or_new(Db_conn_info_.parse_(s));}
|
||||
public Db_conn Get_or_new(String s) {return Get_or_new(Db_conn_info_.parse(s));}
|
||||
public Db_conn Get_or_new(Db_conn_info url) {
|
||||
Db_conn rv = (Db_conn)conn_hash.Get_by(url.Xto_api());
|
||||
if (rv == null) {
|
||||
|
||||
@@ -27,8 +27,8 @@ class Db_rdr__empty implements Db_rdr {
|
||||
public byte Read_byte(String k) {return Byte_.Max_value_127;}
|
||||
public String Read_str(String k) {return String_.Empty;}
|
||||
public DateAdp Read_date_by_str(String k) {return DateAdp_.MinValue;}
|
||||
public int Read_int(String k) {return Int_.MinValue;}
|
||||
public long Read_long(String k) {return Long_.MinValue;}
|
||||
public int Read_int(String k) {return Int_.Min_value;}
|
||||
public long Read_long(String k) {return Long_.Min_value;}
|
||||
public float Read_float(String k) {return Float_.NaN;}
|
||||
public double Read_double(String k) {return Double_.NaN;}
|
||||
public boolean Read_bool_by_byte(String k) {return false;}
|
||||
|
||||
@@ -31,12 +31,12 @@ public class Db_rdr__basic implements Db_rdr {
|
||||
@gplx.Virtual public void Save_bry_in_parts(Io_url url, String tbl, String fld, String crt_key, Object crt_val) {throw Err_.new_unimplemented();}
|
||||
@gplx.Virtual public String Read_str(String k) {try {return (String)rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", String_.Cls_val_name);}}
|
||||
@gplx.Virtual public DateAdp Read_date_by_str(String k) {return DateAdp_.parse_iso8561(Read_str(k));}
|
||||
@gplx.Virtual public int Read_int(String k) {try {return Int_.cast_(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Int_.Cls_val_name);}}
|
||||
@gplx.Virtual public long Read_long(String k) {try {return Long_.cast_(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Long_.Cls_val_name);}}
|
||||
@gplx.Virtual public float Read_float(String k) {try {return Float_.cast_(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Float_.Cls_val_name);}}
|
||||
@gplx.Virtual public double Read_double(String k) {try {return Double_.cast_(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Double_.Cls_val_name);}}
|
||||
@gplx.Virtual public byte Read_byte(String k) {try {return Byte_.cast_(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Byte_.Cls_val_name);}}
|
||||
@gplx.Virtual public boolean Read_bool_by_byte(String k) {try {return Byte_.cast_(rdr.getObject(k)) == 1;} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Bool_.Cls_val_name);}}
|
||||
@gplx.Virtual public int Read_int(String k) {try {return Int_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Int_.Cls_val_name);}}
|
||||
@gplx.Virtual public long Read_long(String k) {try {return Long_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Long_.Cls_val_name);}}
|
||||
@gplx.Virtual public float Read_float(String k) {try {return Float_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Float_.Cls_val_name);}}
|
||||
@gplx.Virtual public double Read_double(String k) {try {return Double_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Double_.Cls_val_name);}}
|
||||
@gplx.Virtual public byte Read_byte(String k) {try {return Byte_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Byte_.Cls_val_name);}}
|
||||
@gplx.Virtual public boolean Read_bool_by_byte(String k) {try {return Byte_.cast(rdr.getObject(k)) == 1;} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Bool_.Cls_val_name);}}
|
||||
@gplx.Virtual public Object Read_obj(String k) {try {return rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Object_.Cls_val_name);}}
|
||||
@gplx.Virtual public void Rls() {
|
||||
try {rdr.close();}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Db_conn_info__mem extends Db_conn_info__base {
|
||||
return rv;
|
||||
}
|
||||
public static Db_conn_info new_(String database) {
|
||||
return Db_conn_info_.parse_(Bld_raw
|
||||
return Db_conn_info_.parse(Bld_raw
|
||||
( "gplx_key", Tid_const
|
||||
, "database", database
|
||||
));
|
||||
|
||||
@@ -33,12 +33,12 @@ public class Db_rdr__mem implements Db_rdr {
|
||||
public byte[] Read_bry_by_str(String k) {return Bry_.new_u8_safe((String)row.Get_by(k));} // NOTE: null b/c db can have NULL
|
||||
@gplx.Virtual public void Save_bry_in_parts(Io_url url, String tbl, String fld, String crt_key, Object crt_val) {throw Err_.new_unimplemented();}
|
||||
public DateAdp Read_date_by_str(String k) {return DateAdp_.parse_iso8561((String)row.Get_by(k));}
|
||||
public byte Read_byte(String k) {return Byte_.cast_(row.Get_by(k));}
|
||||
public int Read_int(String k) {return Int_.cast_(row.Get_by(k));}
|
||||
public long Read_long(String k) {return Long_.cast_(row.Get_by(k));}
|
||||
public float Read_float(String k) {return Float_.cast_(row.Get_by(k));}
|
||||
public double Read_double(String k) {return Double_.cast_(row.Get_by(k));}
|
||||
public boolean Read_bool_by_byte(String k) {return Byte_.cast_(row.Get_by(k)) == 1;}
|
||||
public byte Read_byte(String k) {return Byte_.cast(row.Get_by(k));}
|
||||
public int Read_int(String k) {return Int_.cast(row.Get_by(k));}
|
||||
public long Read_long(String k) {return Long_.cast(row.Get_by(k));}
|
||||
public float Read_float(String k) {return Float_.cast(row.Get_by(k));}
|
||||
public double Read_double(String k) {return Double_.cast(row.Get_by(k));}
|
||||
public boolean Read_bool_by_byte(String k) {return Byte_.cast(row.Get_by(k)) == 1;}
|
||||
public Object Read_obj(String k) {return row.Get_by(k);}
|
||||
public void Rls() {}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Mysql_conn_info extends Db_conn_info__base {
|
||||
public String Uid() {return uid;} private String uid;
|
||||
public String Pwd() {return pwd;} private String pwd;
|
||||
public static Db_conn_info new_(String server, String database, String uid, String pwd) {
|
||||
return Db_conn_info_.parse_(Bld_raw
|
||||
return Db_conn_info_.parse(Bld_raw
|
||||
( "gplx_key", Tid_const
|
||||
, "server", server
|
||||
, "database", database
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Postgres_conn_info extends Db_conn_info__base {
|
||||
public String Uid() {return uid;} private String uid;
|
||||
public String Pwd() {return pwd;} private String pwd;
|
||||
public static Db_conn_info new_(String server, String database, String uid, String pwd) {
|
||||
return Db_conn_info_.parse_(Bld_raw
|
||||
return Db_conn_info_.parse(Bld_raw
|
||||
( "gplx_key", Tid_const
|
||||
, "server", server
|
||||
, "database", database
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Sqlite_conn_info extends Db_conn_info__base {
|
||||
return rv;
|
||||
}
|
||||
public static Db_conn_info load_(Io_url url) {
|
||||
return Db_conn_info_.parse_(Bld_raw
|
||||
return Db_conn_info_.parse(Bld_raw
|
||||
( "gplx_key" , Tid_const
|
||||
, "data source" , url.Xto_api()
|
||||
, "version" , "3"
|
||||
@@ -36,7 +36,7 @@ public class Sqlite_conn_info extends Db_conn_info__base {
|
||||
}
|
||||
public static Db_conn_info make_(Io_url url) {
|
||||
Io_mgr.I.CreateDirIfAbsent(url.OwnerDir());
|
||||
return Db_conn_info_.parse_(Bld_raw
|
||||
return Db_conn_info_.parse(Bld_raw
|
||||
( "gplx_key" , Tid_const
|
||||
, "data source" , url.Xto_api()
|
||||
, "version" , "3"
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Sqlite_engine extends Db_engine_sql_base {
|
||||
}
|
||||
public static final Sqlite_engine _ = new Sqlite_engine();
|
||||
}
|
||||
class Db_rdr__sqlite extends Db_rdr__basic { @Override public byte Read_byte(String k) {try {return (byte)Int_.cast_(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "k", k, "type", Byte_.Cls_val_name);}}
|
||||
class Db_rdr__sqlite extends Db_rdr__basic { @Override public byte Read_byte(String k) {try {return (byte)Int_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "k", k, "type", Byte_.Cls_val_name);}}
|
||||
@Override public boolean Read_bool_by_byte(String k) {
|
||||
try {
|
||||
int val = rdr.getInt(k);
|
||||
@@ -108,14 +108,14 @@ class Sqlite_rdr extends Db_data_rdr { @Override public float ReadFloat(String
|
||||
@Override public boolean ReadBool(String key) {return ReadBoolOr(key, false);}
|
||||
@Override public boolean ReadBoolOr(String key, boolean or) {
|
||||
Object val = Read(key);
|
||||
return val == null ? or : Int_.cast_(val) == 1;
|
||||
return val == null ? or : Int_.cast(val) == 1;
|
||||
}
|
||||
@Override public byte ReadByte(String key) {return ReadByteOr(key, Byte_.Zero);}
|
||||
@Override public byte ReadByteOr(String key, byte or) {
|
||||
Object val = Read(key);
|
||||
return val == null ? or : (byte)Int_.cast_(val);
|
||||
return val == null ? or : (byte)Int_.cast(val);
|
||||
}
|
||||
@Override public long ReadLong(String key) {return ReadLongOr(key, Long_.MinValue);}
|
||||
@Override public long ReadLong(String key) {return ReadLongOr(key, Long_.Min_value);}
|
||||
@Override public long ReadLongOr(String key, long or) {
|
||||
Object val = Read(key);
|
||||
if (val == null) return or;
|
||||
|
||||
@@ -19,11 +19,11 @@ package gplx.dbs.engines.tdbs; import gplx.*; import gplx.dbs.*; import gplx.dbs
|
||||
import org.junit.*;
|
||||
public class TdbConnectInfo_tst {
|
||||
@Test public void Full() {
|
||||
Db_conn_info connectInfo = Db_conn_info_.parse_("gplx_key=tdb;url=C:\\dir\\xmpl.tdb;format=dsv;");
|
||||
Db_conn_info connectInfo = Db_conn_info_.parse("gplx_key=tdb;url=C:\\dir\\xmpl.tdb;format=dsv;");
|
||||
tst_Parse(connectInfo, Io_url_.new_any_("C:\\dir\\xmpl.tdb"), "dsv");
|
||||
}
|
||||
@Test public void DefaultFormat() {
|
||||
Db_conn_info connectInfo = Db_conn_info_.parse_("gplx_key=tdb;url=C:\\dir\\xmpl.tdb"); // dsv Format inferred
|
||||
Db_conn_info connectInfo = Db_conn_info_.parse("gplx_key=tdb;url=C:\\dir\\xmpl.tdb"); // dsv Format inferred
|
||||
tst_Parse(connectInfo, Io_url_.new_any_("C:\\dir\\xmpl.tdb"), "dsv");
|
||||
}
|
||||
void tst_Parse(Db_conn_info connectInfo, Io_url url, String format) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.dbs.engines.tdbs; import gplx.*; import gplx.dbs.*; import gplx.dbs
|
||||
import gplx.core.criterias.*; import gplx.lists.*; /*GfoNde*/ import gplx.dbs.qrys.*;
|
||||
class TdbDeleteWkr implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engineObj, Db_qry cmdObj) {
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry_delete cmd = (Db_qry_delete)cmdObj;
|
||||
TdbEngine engine = TdbEngine.cast(engineObj); Db_qry_delete cmd = (Db_qry_delete)cmdObj;
|
||||
TdbTable tbl = engine.FetchTbl(cmd.Base_table());
|
||||
List_adp deleted = List_adp_.new_();
|
||||
int rv = 0;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TdbEngine implements Db_engine {
|
||||
wkrs.Add(Db_qry_.Tid_flush, TdbFlushWkr.new_());
|
||||
}
|
||||
public static TdbEngine as_(Object obj) {return obj instanceof TdbEngine ? (TdbEngine)obj : null;}
|
||||
public static TdbEngine cast_(Object obj) {try {return (TdbEngine)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TdbEngine.class, obj);}}
|
||||
public static TdbEngine cast(Object obj) {try {return (TdbEngine)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TdbEngine.class, obj);}}
|
||||
}
|
||||
interface Db_qryWkr {
|
||||
Object Exec(Db_engine engine, Db_qry cmd);
|
||||
|
||||
@@ -27,5 +27,5 @@ public class TdbFile {
|
||||
}
|
||||
public static final int MainFileId = 1;
|
||||
public static TdbFile as_(Object obj) {return obj instanceof TdbFile ? (TdbFile)obj : null;}
|
||||
public static TdbFile cast_(Object obj) {try {return (TdbFile)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TdbFile.class, obj);}}
|
||||
public static TdbFile cast(Object obj) {try {return (TdbFile)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TdbFile.class, obj);}}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.dbs.engines.tdbs; import gplx.*; import gplx.dbs.*; import gplx.dbs
|
||||
import gplx.lists.*; /*GfoNde*/ import gplx.dbs.qrys.*;
|
||||
class TdbFlushWkr implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engineObj, Db_qry cmdObj) {
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry_flush cmd = Db_qry_flush.cast_(cmdObj);
|
||||
TdbEngine engine = TdbEngine.cast(engineObj); Db_qry_flush cmd = Db_qry_flush.cast(cmdObj);
|
||||
if (Array_.Len(cmd.TableNames()) == 0)
|
||||
engine.FlushAll();
|
||||
else {
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.dbs.engines.tdbs; import gplx.*; import gplx.dbs.*; import gplx.dbs
|
||||
import gplx.lists.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*;
|
||||
class TdbInsertWkr implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engineObj, Db_qry cmdObj) {
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry_insert cmd = (Db_qry_insert)cmdObj;
|
||||
TdbEngine engine = TdbEngine.cast(engineObj); Db_qry_insert cmd = (Db_qry_insert)cmdObj;
|
||||
|
||||
TdbTable tbl = engine.FetchTbl(cmd.Base_table());
|
||||
tbl.IsDirty_set(true);
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.criterias.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*;
|
||||
import gplx.lists.*; /*ComparerAble*/ import gplx.stores.*; /*GfoNdeRdr*/
|
||||
class TdbSelectWkr implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engineObj, Db_qry cmdObj) {
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry__select_cmd cmd = (Db_qry__select_cmd)cmdObj;
|
||||
TdbEngine engine = TdbEngine.cast(engineObj); Db_qry__select_cmd cmd = (Db_qry__select_cmd)cmdObj;
|
||||
if (cmd.From().Tbls().Count() > 1) throw Err_.new_("gplx.tdbs", "joins not supported for tdbs", "sql", cmd.Xto_sql());
|
||||
|
||||
TdbTable tbl = engine.FetchTbl(cmd.From().BaseTable().TblName());
|
||||
|
||||
@@ -61,5 +61,5 @@ public class TdbTable {
|
||||
}
|
||||
DsvStoreLayout layout;
|
||||
public static TdbTable as_(Object obj) {return obj instanceof TdbTable ? (TdbTable)obj : null;}
|
||||
public static TdbTable cast_(Object obj) {try {return (TdbTable)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TdbTable.class, obj);}}
|
||||
public static TdbTable cast(Object obj) {try {return (TdbTable)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TdbTable.class, obj);}}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.criterias.*; import gplx.lists.*; /*GfoNde*/
|
||||
import gplx.dbs.qrys.*;
|
||||
class TdbUpdateWkr implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engineObj, Db_qry cmdObj) {
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry_update cmd = (Db_qry_update)cmdObj;
|
||||
TdbEngine engine = TdbEngine.cast(engineObj); Db_qry_update cmd = (Db_qry_update)cmdObj;
|
||||
|
||||
int rv = 0;
|
||||
TdbTable tbl = engine.FetchTbl(cmd.Base_table());
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Tdb_conn_info extends Db_conn_info__base {
|
||||
public Io_url Url() {return url;} Io_url url;
|
||||
@Override public String Tid() {return Tid_const;} public static final String Tid_const = "tdb";
|
||||
public static Db_conn_info new_(Io_url url) {
|
||||
return Db_conn_info_.parse_(Bld_raw
|
||||
return Db_conn_info_.parse(Bld_raw
|
||||
( "gplx_key", Tid_const
|
||||
, "url", url.Raw()
|
||||
));
|
||||
|
||||
@@ -25,13 +25,13 @@ public class Meta_parser__fld {
|
||||
Meta_parser__fld_itm type_itm = (Meta_parser__fld_itm)type_obj;
|
||||
rdr.Pos_add(type_itm.Word().length);
|
||||
int paren_itms_count = type_itm.Paren_itms_count();
|
||||
int len_1 = Int_.MinValue, len_2 = Int_.MinValue;
|
||||
int len_1 = Int_.Min_value, len_2 = Int_.Min_value;
|
||||
if (paren_itms_count > 0) {
|
||||
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Paren_bgn);
|
||||
len_1 = rdr.Skip_ws().Read_int_to_non_num(); if (len_1 == Int_.MinValue) throw Err_.new_wo_type("invalid fld len_1", "snip", rdr.Mid_by_len_safe(40));
|
||||
len_1 = rdr.Skip_ws().Read_int_to_non_num(); if (len_1 == Int_.Min_value) throw Err_.new_wo_type("invalid fld len_1", "snip", rdr.Mid_by_len_safe(40));
|
||||
if (paren_itms_count == 2) {
|
||||
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Comma);
|
||||
len_2 = rdr.Skip_ws().Read_int_to_non_num(); if (len_2 == Int_.MinValue) throw Err_.new_wo_type("invalid fld len_2", "snip", rdr.Mid_by_len_safe(40));
|
||||
len_2 = rdr.Skip_ws().Read_int_to_non_num(); if (len_2 == Int_.Min_value) throw Err_.new_wo_type("invalid fld len_2", "snip", rdr.Mid_by_len_safe(40));
|
||||
}
|
||||
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Paren_end);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ class Meta_parser__fld_fxt {
|
||||
private final Meta_parser__fld fld_parser = new Meta_parser__fld();
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
public void Clear() {}
|
||||
public Meta_type_itm Make_type(int tid_ansi) {return new Meta_type_itm(tid_ansi, -1, null, Int_.MinValue, Int_.MinValue);}
|
||||
public Meta_type_itm Make_type(int tid_ansi, int len_1) {return new Meta_type_itm(tid_ansi, -1, null, len_1, Int_.MinValue);}
|
||||
public Meta_type_itm Make_type(int tid_ansi) {return new Meta_type_itm(tid_ansi, -1, null, Int_.Min_value, Int_.Min_value);}
|
||||
public Meta_type_itm Make_type(int tid_ansi, int len_1) {return new Meta_type_itm(tid_ansi, -1, null, len_1, Int_.Min_value);}
|
||||
public Meta_type_itm Make_type(int tid_ansi, int len_1, int len_2) {return new Meta_type_itm(tid_ansi, -1, null, len_1, len_2);}
|
||||
public Meta_fld_itm Make_fld(String name, int tid_ansi, int nullable) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
|
||||
public Meta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
|
||||
|
||||
@@ -46,7 +46,7 @@ class Meta_parser__tbl_fxt {
|
||||
Meta_tbl_itm rv = new Meta_tbl_itm(tbl_name, "NONE");
|
||||
int len = fld_names.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
rv.Flds().Add(new Meta_fld_itm(fld_names[i], new Meta_type_itm(Db_meta_fld.Tid_int, Sqlite_tid.Tid_int, Bry_.new_a7("int"), Int_.MinValue, Int_.MinValue)));
|
||||
rv.Flds().Add(new Meta_fld_itm(fld_names[i], new Meta_type_itm(Db_meta_fld.Tid_int, Sqlite_tid.Tid_int, Bry_.new_a7("int"), Int_.Min_value, Int_.Min_value)));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
}
|
||||
Class<?> val_type = val.getClass();
|
||||
if (val_type == Bool_.Cls_ref_type)
|
||||
sb.Add_obj(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"
|
||||
sb.Add_obj(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
|
||||
( val_type == Byte_.Cls_ref_type || val_type == Short_.Cls_ref_type
|
||||
|| val_type == Int_.Cls_ref_type || val_type == Long_.Cls_ref_type
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Sql_qry_wtr_iosql_tst {
|
||||
@Test public void Url() {
|
||||
fld = IoItm_base_.Prop_Path;
|
||||
tst_Write("url='C:\\fil.txt'", ioCrt_(fld, Criteria_.eq_("C:\\fil.txt")));
|
||||
tst_Write("url IOMATCH '*.txt'", ioCrt_(fld, Criteria_ioMatch.parse_(true, "*.txt", false)));
|
||||
tst_Write("url IOMATCH '*.txt'", ioCrt_(fld, Criteria_ioMatch.parse(true, "*.txt", false)));
|
||||
}
|
||||
@Test public void Binary() {
|
||||
// parentheses around lhs and rhs
|
||||
|
||||
@@ -42,7 +42,7 @@ class Sql_select_fld_count extends Sql_select_fld_func_base {
|
||||
@Override public void GroupBy_type(GfoFld fld) {this.ValType_set(IntClassXtn._);}
|
||||
@Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {
|
||||
if (groupByVal == null) return 1;
|
||||
return Int_.cast_(groupByVal) + 1;
|
||||
return Int_.cast(groupByVal) + 1;
|
||||
}
|
||||
}
|
||||
class Sql_select_fld_sum extends Sql_select_fld_func_base {
|
||||
@@ -50,8 +50,8 @@ class Sql_select_fld_sum extends Sql_select_fld_func_base {
|
||||
@Override public String XtoSql_functionName() {return "SUM";}
|
||||
@Override public void GroupBy_type(GfoFld fld) {this.ValType_set(IntClassXtn._);}
|
||||
@Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {
|
||||
if (groupByVal == null) return Int_.cast_(curVal);
|
||||
return Int_.cast_(groupByVal) + Int_.cast_(curVal);
|
||||
if (groupByVal == null) return Int_.cast(curVal);
|
||||
return Int_.cast(groupByVal) + Int_.cast(curVal);
|
||||
}
|
||||
}
|
||||
class Sql_select_fld_minMax extends Sql_select_fld_func_base {
|
||||
|
||||
Reference in New Issue
Block a user