mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.3.2.1
This commit is contained in:
22
140_dbs/src/gplx/dbs/Db_batch_wkr.java
Normal file
22
140_dbs/src/gplx/dbs/Db_batch_wkr.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public interface Db_batch_wkr {
|
||||
void Batch_bgn();
|
||||
void Batch_end();
|
||||
}
|
||||
43
140_dbs/src/gplx/dbs/Db_batch_wkr__attach.java
Normal file
43
140_dbs/src/gplx/dbs/Db_batch_wkr__attach.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_batch_wkr__attach implements Db_batch_wkr {
|
||||
private final Db_conn conn;
|
||||
private final ListAdp list = ListAdp_.new_();
|
||||
public Db_batch_wkr__attach Add(String alias, Io_url url) {list.Add(new Db_batch_wkr__attach_itm(alias, url)); return this;}
|
||||
public Db_batch_wkr__attach(Db_conn conn) {this.conn = conn;}
|
||||
public void Batch_bgn() {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_wkr__attach_itm itm = (Db_batch_wkr__attach_itm)list.FetchAt(i);
|
||||
conn.Exec_env_db_attach(itm.Alias(), itm.Url());
|
||||
}
|
||||
}
|
||||
public void Batch_end() {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_wkr__attach_itm itm = (Db_batch_wkr__attach_itm)list.FetchAt(i);
|
||||
conn.Exec_env_db_detach(itm.Alias());
|
||||
}
|
||||
}
|
||||
}
|
||||
class Db_batch_wkr__attach_itm {
|
||||
public Db_batch_wkr__attach_itm(String alias, Io_url url) {this.alias = alias; this.url = url;}
|
||||
public String Alias() {return alias;} private final String alias;
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
}
|
||||
26
140_dbs/src/gplx/dbs/Db_batch_wkr__msg.java
Normal file
26
140_dbs/src/gplx/dbs/Db_batch_wkr__msg.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_batch_wkr__msg implements Db_batch_wkr {
|
||||
private final Gfo_usr_dlg usr_dlg; private final String msg_pre;
|
||||
public Db_batch_wkr__msg(Gfo_usr_dlg usr_dlg, String msg_pre) {this.usr_dlg = usr_dlg; this.msg_pre = msg_pre;}
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;}
|
||||
public String Msg() {return msg;} public Db_batch_wkr__msg Msg_(String v) {msg = v; return this;} private String msg;
|
||||
public void Batch_bgn() {usr_dlg.Plog_many("", "", "bgn:" + msg_pre + "." + msg);}
|
||||
public void Batch_end() {usr_dlg.Plog_many("", "", "end:" + msg_pre + "." + msg);}
|
||||
}
|
||||
31
140_dbs/src/gplx/dbs/Db_batch_wkr__sql.java
Normal file
31
140_dbs/src/gplx/dbs/Db_batch_wkr__sql.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_batch_wkr__sql implements Db_batch_wkr {
|
||||
private final Db_conn conn; private String sql;
|
||||
public Db_batch_wkr__sql(Db_conn conn, String... lines) {this.conn = conn; this.sql = String_.Concat_lines_nl_skip_last(lines);}
|
||||
public String Sql() {return sql;}
|
||||
public Db_batch_wkr__sql Sql_(String... lines) {sql = String_.Concat_lines_nl_skip_last(lines); return this;}
|
||||
public void Batch_bgn() {
|
||||
conn.Txn_bgn();
|
||||
conn.Exec_sql(sql);
|
||||
conn.Txn_end();
|
||||
}
|
||||
public void Batch_end() {
|
||||
}
|
||||
}
|
||||
@@ -26,18 +26,24 @@ public class Db_conn {
|
||||
}
|
||||
public Db_url Url() {return engine.Url();}
|
||||
public Db_txn_mgr Txn_mgr() {return txn_mgr;} private final Db_txn_mgr txn_mgr;
|
||||
public void Txn_bgn() {txn_mgr.Txn_bgn();}
|
||||
public void Txn_commit() {txn_mgr.Txn_end(); txn_mgr.Txn_bgn();}
|
||||
public void Txn_end() {txn_mgr.Txn_end();}
|
||||
public Db_stmt Stmt_insert(String tbl, Db_meta_fld_list flds) {return engine.New_stmt_prep(Db_qry_insert.new_(tbl, flds.To_str_ary()));}
|
||||
public Db_stmt Stmt_insert(String tbl, String... cols) {return engine.New_stmt_prep(Db_qry_insert.new_(tbl, cols));}
|
||||
public Db_stmt Stmt_update(String tbl, String[] where, String... cols) {return engine.New_stmt_prep(Db_qry_update.new_(tbl, where, cols));}
|
||||
public Db_stmt Stmt_update_exclude(String tbl, Db_meta_fld_list flds, String... where) {return engine.New_stmt_prep(Db_qry_update.new_(tbl, where, flds.To_str_ary_exclude(where)));}
|
||||
public Db_stmt Stmt_delete(String tbl, String... where) {return engine.New_stmt_prep(Db_qry_delete.new_(tbl, where));}
|
||||
public Db_stmt Stmt_select(String tbl, String[] cols, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, cols));}
|
||||
public Db_stmt Stmt_select(String tbl, Db_meta_fld_list flds, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, flds.To_str_ary()));}
|
||||
public Db_stmt Stmt_select(String tbl, String[] cols, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, cols, null));}
|
||||
public Db_stmt Stmt_select(String tbl, Db_meta_fld_list flds, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, flds.To_str_ary(), null));}
|
||||
public Db_stmt Stmt_select_order(String tbl, Db_meta_fld_list flds, String[] where, String... orderbys) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, flds.To_str_ary(), orderbys));}
|
||||
public void Exec_create_tbl_and_idx(Db_meta_tbl meta) {
|
||||
engine.Exec_ddl_create_tbl(meta);
|
||||
engine.Exec_ddl_create_idx(Gfo_usr_dlg_.Null, meta.Idxs());
|
||||
}
|
||||
public void Exec_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... idxs) {engine.Exec_ddl_create_idx(usr_dlg, idxs);}
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {engine.Exec_env_db_attach(alias, db_url);}
|
||||
public void Exec_env_db_detach(String alias) {engine.Exec_env_db_detach(alias);}
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {engine.Exec_ddl_append_fld(tbl, fld);}
|
||||
public Db_stmt Rls_reg(Db_stmt stmt) {rls_list.Add(stmt); return stmt;}
|
||||
public void Conn_term() {
|
||||
@@ -54,4 +60,23 @@ public class Db_conn {
|
||||
public DataRdr Exec_qry_as_rdr(Db_qry qry) {return DataRdr_.cast_(engine.Exec_as_obj(qry));}
|
||||
public int Exec_sql(String sql) {return this.Exec_qry(Db_qry_sql.dml_(sql));}
|
||||
public DataRdr Exec_sql_as_rdr(String sql) {return this.Exec_qry_as_rdr(Db_qry_sql.rdr_(sql));}
|
||||
public void Exec_sql_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... idxs) {engine.Exec_ddl_create_idx(usr_dlg, idxs);}
|
||||
public void Exec_sql(Db_batch_wkr... wkrs) {
|
||||
int len = wkrs.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_wkr wkr = wkrs[i];
|
||||
wkr.Batch_bgn();
|
||||
wkr.Batch_end();
|
||||
}
|
||||
}
|
||||
public void Exec_sql__vacuum(Db_batch_wkr__msg msg) {
|
||||
msg.Msg_("vaccuum");
|
||||
Exec_sql(msg, Batch_sql("VACCUUM;"));
|
||||
}
|
||||
public void Exec_sql__idx(Db_batch_wkr__msg msg, Db_meta_idx... idxs) {
|
||||
engine.Exec_ddl_create_idx(msg.Usr_dlg(), idxs);
|
||||
}
|
||||
public Db_batch_wkr__msg Batch_msg(Gfo_usr_dlg usr_dlg, String msg_pre) {return new Db_batch_wkr__msg(usr_dlg, msg_pre);}
|
||||
public Db_batch_wkr__attach Batch_attach(String alias, Io_url url) {return new Db_batch_wkr__attach(this).Add(alias, url);}
|
||||
public Db_batch_wkr__sql Batch_sql(String... lines) {return new Db_batch_wkr__sql(this, lines);}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.qrys.*;
|
||||
public class Db_qry_ {
|
||||
public static Db_qry_select select_cols_(String tbl, Criteria crt, String... cols){return select_().From_(tbl).Where_(crt).Cols_(cols);}
|
||||
public static Db_qry_select select_val_(String tbl, String col, Criteria crt) {return select_().From_(tbl).Where_(crt).Cols_(col);}
|
||||
public static Db_qry_select select_tbl_(String tbl) {return select_().From_(tbl);}
|
||||
public static Db_qry_select select_() {return Db_qry_select.new_();}
|
||||
public static Db_qry__select_cmd select_cols_(String tbl, Criteria crt, String... cols){return select_().From_(tbl).Where_(crt).Cols_(cols);}
|
||||
public static Db_qry__select_cmd select_val_(String tbl, String col, Criteria crt) {return select_().From_(tbl).Where_(crt).Cols_(col);}
|
||||
public static Db_qry__select_cmd select_tbl_(String tbl) {return select_().From_(tbl);}
|
||||
public static Db_qry__select_cmd select_() {return Db_qry__select_cmd.new_();}
|
||||
public static Db_qry_delete delete_(String tbl, Criteria crt) {return Db_qry_delete.new_(tbl, crt);}
|
||||
public static Db_qry_delete delete_tbl_(String tbl) {return Db_qry_delete.new_(tbl);}
|
||||
public static Db_qry_insert insert_(String tbl) {return new Db_qry_insert(tbl);}
|
||||
|
||||
@@ -32,11 +32,11 @@ public class Db_stmt_ {
|
||||
return conn.Stmt_new(qry);
|
||||
}
|
||||
public static Db_stmt new_select_(Db_conn conn, String tbl, String[] where, String... flds) {
|
||||
Db_qry_select qry = Db_qry_.select_cols_(tbl, Db_crt_.eq_many_(where), flds);
|
||||
Db_qry__select_cmd qry = Db_qry_.select_cols_(tbl, Db_crt_.eq_many_(where), flds);
|
||||
return conn.Stmt_new(qry);
|
||||
}
|
||||
public static Db_stmt new_select_in_(Db_conn conn, String tbl, String in_fld, Object[] in_vals, String... flds) {
|
||||
Db_qry_select qry = Db_qry_.select_cols_(tbl, Db_crt_.in_(in_fld, in_vals), flds).OrderBy_asc_(in_fld);
|
||||
Db_qry__select_cmd qry = Db_qry_.select_cols_(tbl, Db_crt_.in_(in_fld, in_vals), flds).OrderBy_asc_(in_fld);
|
||||
return conn.Stmt_new(qry);
|
||||
}
|
||||
public static Db_stmt new_select_all_(Db_conn conn, String tbl) {
|
||||
|
||||
@@ -32,4 +32,6 @@ public interface Db_engine {
|
||||
void Exec_ddl_create_tbl(Db_meta_tbl meta);
|
||||
void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary);
|
||||
void Exec_ddl_append_fld(String tbl, Db_meta_fld fld);
|
||||
void Exec_env_db_attach(String alias, Io_url db_url);
|
||||
void Exec_env_db_detach(String alias);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
String sql = this.SqlWtr().Xto_str(qry, false); // DBG: Tfds.Write(sql);
|
||||
return qry.Exec_is_rdr() ? (Object)this.Exec_as_rdr(sql) : this.Exec_as_int(sql);
|
||||
}
|
||||
private int Exec_as_int(String sql) {
|
||||
protected int Exec_as_int(String sql) {
|
||||
try {
|
||||
Statement cmd = New_stmt_exec(sql);
|
||||
return cmd.executeUpdate(sql);
|
||||
@@ -65,6 +65,8 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {
|
||||
Exec_as_int(Db_sqlbldr__sqlite.I.Bld_alter_tbl_add(tbl, fld));
|
||||
}
|
||||
@gplx.Virtual public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
@gplx.Virtual public void Exec_env_db_detach(String alias) {}
|
||||
@gplx.Virtual public DataRdr New_rdr(ResultSet rdr, String sql) {return gplx.stores.Db_data_rdr_.new_(rdr, sql);}
|
||||
@gplx.Virtual public Sql_qry_wtr SqlWtr() {return Sql_qry_wtr_.new_ansi();}
|
||||
@gplx.Internal protected abstract Connection Conn_new();
|
||||
|
||||
@@ -40,5 +40,7 @@ public class Db_engine__mem implements Db_engine {
|
||||
}
|
||||
public void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {} // TODO: implement unique index
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {}
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Exec_env_db_detach(String alias) {}
|
||||
public static final Db_engine__mem _ = new Db_engine__mem(); Db_engine__mem() {}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Mem_tbl {
|
||||
String[] select = null; Criteria where = null;
|
||||
Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.as_(stmt.Qry());
|
||||
if (qry == null) {
|
||||
Db_qry_select qry2 = (Db_qry_select)stmt.Qry();
|
||||
Db_qry__select_cmd qry2 = (Db_qry__select_cmd)stmt.Qry();
|
||||
select = qry2.Cols_ary();
|
||||
where = qry2.Where();
|
||||
}
|
||||
|
||||
@@ -32,5 +32,7 @@ public class Null_engine implements Db_engine {
|
||||
public void Exec_ddl_create_tbl(Db_meta_tbl meta) {}
|
||||
public void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {}
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {}
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Exec_env_db_detach(String alias) {}
|
||||
public static final Null_engine _ = new Null_engine(); Null_engine() {}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public class Sqlite_engine extends Db_engine_sql_base {
|
||||
}
|
||||
@Override public DataRdr New_rdr(ResultSet rdr, String commandText) {return Sqlite_rdr.new_(rdr, commandText);}
|
||||
@Override public Db_rdr New_rdr_clone() {return new Db_rdr__sqlite();}
|
||||
@Override public void Exec_env_db_attach(String alias, Io_url db_url) {Exec_as_int(String_.Format("ATTACH '{0}' AS {1};", db_url.Raw(), alias));}
|
||||
@Override public void Exec_env_db_detach(String alias) {Exec_as_int(String_.Format("DETACH {0};", alias));}
|
||||
static boolean loaded = false;
|
||||
@gplx.Internal @Override protected Connection Conn_new() {
|
||||
if (!loaded) {
|
||||
|
||||
@@ -57,7 +57,8 @@ public class TdbEngine implements Db_engine {
|
||||
public void Exec_ddl_create_tbl(Db_meta_tbl meta) {throw Err_.not_implemented_();}
|
||||
public void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {throw Err_.not_implemented_();}
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {throw Err_.not_implemented_();}
|
||||
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Exec_env_db_detach(String alias) {}
|
||||
|
||||
HashAdp wkrs = HashAdp_.new_(); TdbDbLoadMgr loadMgr = TdbDbLoadMgr.new_(); TdbDbSaveMgr saveMgr = TdbDbSaveMgr.new_();
|
||||
public static final TdbEngine _ = new TdbEngine();
|
||||
|
||||
@@ -20,11 +20,11 @@ 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 = (Db_qry_select)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_key_("gplx.tdbs", "joins not supported for tdbs").Add("sql", cmd.Xto_sql());
|
||||
|
||||
TdbTable tbl = engine.FetchTbl(cmd.From().BaseTable().TblName());
|
||||
GfoNdeList rv = (cmd.Where() == Db_qry_.WhereAll && cmd.Limit() == Db_qry_select.Limit_disabled) ? rv = tbl.Rows() : FilterRecords(tbl, cmd.Where(), cmd.Limit());
|
||||
GfoNdeList rv = (cmd.Where() == Db_qry_.WhereAll && cmd.Limit() == Db_qry__select_cmd.Limit_disabled) ? rv = tbl.Rows() : FilterRecords(tbl, cmd.Where(), cmd.Limit());
|
||||
if (cmd.GroupBy() != null)
|
||||
rv = TdbGroupByWkr.GroupByExec(cmd, rv, tbl);
|
||||
if (cmd.OrderBy() != null) { // don't use null pattern here; if null ORDER BY, then don't call .Sort on GfoNdeList
|
||||
@@ -47,7 +47,7 @@ class TdbSelectWkr implements Db_qryWkr {
|
||||
public static final TdbSelectWkr _ = new TdbSelectWkr(); TdbSelectWkr() {}
|
||||
}
|
||||
class TdbGroupByWkr {
|
||||
public static GfoNdeList GroupByExec(Db_qry_select select, GfoNdeList selectRows, TdbTable tbl) {
|
||||
public static GfoNdeList GroupByExec(Db_qry__select_cmd select, GfoNdeList selectRows, TdbTable tbl) {
|
||||
GfoNdeList rv = GfoNdeList_.new_();
|
||||
OrderedHash groupByHash = OrderedHash_.new_();
|
||||
ListAdp groupByFlds = select.GroupBy().Flds();
|
||||
|
||||
@@ -17,11 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_select implements Db_qry {
|
||||
public class Db_qry__select_cmd implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_select;}
|
||||
public boolean Exec_is_rdr() {return true;}
|
||||
public String Base_table() {return from.BaseTable().TblName();}
|
||||
public String Xto_sql() {return Sql_qry_wtr_.I.Xto_str(this, false);}
|
||||
public String Xto_sql_prepare() {return Sql_qry_wtr_.I.Xto_str(this, true);}
|
||||
public DataRdr Exec_qry_as_rdr(Db_conn conn) {return conn.Exec_qry_as_rdr(this);}
|
||||
public GfoNde ExecRdr_nde(Db_conn conn) {
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
@@ -48,13 +49,13 @@ public class Db_qry_select implements Db_qry {
|
||||
}
|
||||
|
||||
public Sql_from From() {return from;} Sql_from from;
|
||||
public Db_qry_select From_(String tblName) {return From_(tblName, null);}
|
||||
public Db_qry_select From_(String tblName, String alias) {
|
||||
public Db_qry__select_cmd From_(String tblName) {return From_(tblName, null);}
|
||||
public Db_qry__select_cmd From_(String tblName, String alias) {
|
||||
if (from != null) throw Err_.new_("super table already defined").Add("from", from.Tbls().Count());
|
||||
from = Sql_from.new_(Sql_tbl_src.new_().JoinType_(Sql_join_itmType.From).TblName_(tblName).Alias_(alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Join_(String name, String alias, Sql_join_itm... ary) {
|
||||
public Db_qry__select_cmd Join_(String name, String alias, Sql_join_itm... ary) {
|
||||
if (from == null) throw Err_.new_("super table is not defined");
|
||||
Sql_tbl_src tbl = Sql_tbl_src.new_().JoinType_(Sql_join_itmType.Inner).TblName_(name).Alias_(alias);
|
||||
for (Sql_join_itm itm : ary)
|
||||
@@ -65,50 +66,50 @@ public class Db_qry_select implements Db_qry {
|
||||
|
||||
public Sql_select Cols() {return cols;} Sql_select cols = Sql_select.All;
|
||||
public String[] Cols_ary() {return cols.Flds().To_str_ary();}
|
||||
public Db_qry_select Cols_all_() {return this;}
|
||||
public Db_qry_select Cols_alias_(String expr, String alias) {
|
||||
public Db_qry__select_cmd Cols_all_() {return this;}
|
||||
public Db_qry__select_cmd Cols_alias_(String expr, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(expr, alias);
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_(String... ary) {
|
||||
public Db_qry__select_cmd Cols_(String... ary) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
for (String itm : ary)
|
||||
cols.Add(itm);
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_max(String fld) {return Cols_groupBy_max(fld, fld);}
|
||||
public Db_qry_select Cols_groupBy_max(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_max(String fld) {return Cols_groupBy_max(fld, fld);}
|
||||
public Db_qry__select_cmd Cols_groupBy_max(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_max(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_min(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_min(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_min(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_count(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_count(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_count(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_sum(String fld) {return Cols_groupBy_sum(fld, fld);}
|
||||
public Db_qry_select Cols_groupBy_sum(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_sum(String fld) {return Cols_groupBy_sum(fld, fld);}
|
||||
public Db_qry__select_cmd Cols_groupBy_sum(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_sum(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Criteria Where() {return where;} public Db_qry_select Where_(Criteria crt) {where = crt; return this;} Criteria where;
|
||||
public Criteria Where() {return where;} public Db_qry__select_cmd Where_(Criteria crt) {where = crt; return this;} Criteria where;
|
||||
public Sql_order_by OrderBy() {return orderBy;} Sql_order_by orderBy = null;
|
||||
public Db_qry_select OrderBy_(String fieldName, boolean ascending) {
|
||||
public Db_qry__select_cmd OrderBy_(String fieldName, boolean ascending) {
|
||||
Sql_order_by_itm item = Sql_order_by_itm.new_(fieldName, ascending);
|
||||
orderBy = Sql_order_by.new_(item);
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select OrderBy_asc_(String fieldName) {return OrderBy_(fieldName, true);}
|
||||
public Db_qry_select OrderBy_many_(String... fldNames) {
|
||||
public Db_qry__select_cmd OrderBy_asc_(String fieldName) {return OrderBy_(fieldName, true);}
|
||||
public Db_qry__select_cmd OrderBy_many_(String... fldNames) {
|
||||
Sql_order_by_itm[] ary = new Sql_order_by_itm[fldNames.length];
|
||||
for (int i = 0; i < fldNames.length; i++)
|
||||
ary[i] = Sql_order_by_itm.new_(fldNames[i], true);
|
||||
@@ -116,15 +117,15 @@ public class Db_qry_select implements Db_qry {
|
||||
return this;
|
||||
}
|
||||
public Sql_group_by GroupBy() {return groupBy;} Sql_group_by groupBy = null;
|
||||
public Db_qry_select GroupBy_(String... flds) {
|
||||
public Db_qry__select_cmd GroupBy_(String... flds) {
|
||||
if (groupBy != null) throw Err_.new_("group by already defined").Add("group", groupBy);
|
||||
groupBy = Sql_group_by.new_(flds);
|
||||
return this;
|
||||
}
|
||||
public String Indexed_by() {return indexed_by;} public Db_qry_select Indexed_by_(String v) {indexed_by = v; return this;} private String indexed_by;
|
||||
public Db_qry_select Distinct_() {cols.Distinct_set(true); return this;}
|
||||
public String Indexed_by() {return indexed_by;} public Db_qry__select_cmd Indexed_by_(String v) {indexed_by = v; return this;} private String indexed_by;
|
||||
public Db_qry__select_cmd Distinct_() {cols.Distinct_set(true); return this;}
|
||||
public int Limit() {return limit;} int limit = -1; public static final int Limit_disabled = -1;
|
||||
public Db_qry_select Limit_(int v) {this.limit = v; return this;}
|
||||
public Db_qry__select_cmd Limit_(int v) {this.limit = v; return this;}
|
||||
|
||||
public static Db_qry_select new_() {return new Db_qry_select();} Db_qry_select() {}
|
||||
public static Db_qry__select_cmd new_() {return new Db_qry__select_cmd();} Db_qry__select_cmd() {}
|
||||
}
|
||||
@@ -59,11 +59,29 @@ public class Db_qry__select_in_tbl implements Db_qry {
|
||||
return sb.XtoStr();
|
||||
}
|
||||
}
|
||||
public static Db_qry__select_in_tbl new_(String base_table, String[] where_flds, String[] select_flds) {
|
||||
Db_qry__select_in_tbl rv = new Db_qry__select_in_tbl(base_table, select_flds, where_flds, null, null, null, null);
|
||||
public static Db_qry__select_in_tbl new_(String base_table, String[] where_flds, String[] select_flds, String[] order_flds) {
|
||||
String order_by_sql = null;
|
||||
if (order_flds != Order_by_null) {
|
||||
int len = order_flds.length;
|
||||
switch (len) {
|
||||
case 0: break;
|
||||
case 1: order_by_sql = order_flds[0]; break;
|
||||
default:
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String order_fld = order_flds[i];
|
||||
if (i != 0) bfr.Add_byte_comma();
|
||||
bfr.Add_str_ascii(order_fld);
|
||||
}
|
||||
order_by_sql = bfr.Xto_str_and_clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Db_qry__select_in_tbl rv = new Db_qry__select_in_tbl(base_table, select_flds, where_flds, null, null, order_by_sql, null);
|
||||
rv.where = where_flds.length == 0 ? Db_crt_.Wildcard : Db_crt_.eq_many_(where_flds);
|
||||
return rv;
|
||||
}
|
||||
public static Db_qry__select_in_tbl as_(Object obj) {return obj instanceof Db_qry__select_in_tbl ? (Db_qry__select_in_tbl)obj : null;}
|
||||
public static final String[] Where_flds__all = String_.Ary_empty;
|
||||
public static final String[] Order_by_null = null;
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class Db_qry_insert implements Db_qry_arg_owner {
|
||||
}
|
||||
public Db_qry_arg_owner Key_arg_(String k, int v) {return Arg_obj_type_(k, v, Db_val_type.Tid_int32);}
|
||||
public Db_qry_arg_owner Key_arg_(String k, String v) {return Arg_obj_type_(k, v, Db_val_type.Tid_varchar);}
|
||||
public Db_qry_select Select() {return select;} Db_qry_select select;
|
||||
public Db_qry_insert Select_(Db_qry_select qry) {this.select = qry; return this;}
|
||||
public Db_qry__select_cmd Select() {return select;} Db_qry__select_cmd select;
|
||||
public Db_qry_insert Select_(Db_qry__select_cmd qry) {this.select = qry; return this;}
|
||||
public Db_qry_insert Cols_(String... ary) {
|
||||
if (cols == null) cols = Sql_select_fld_list.new_();
|
||||
for (String fld : ary)
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_select_tst {
|
||||
@Before public void setup() {
|
||||
cmd = Db_qry_select.new_();
|
||||
} Db_qry_select cmd; String expd;
|
||||
cmd = Db_qry__select_cmd.new_();
|
||||
} Db_qry__select_cmd cmd; String expd;
|
||||
@Test public void Basic() {
|
||||
cmd.Cols_("fld0", "fld1").From_("tbl0");
|
||||
expd = "SELECT fld0, fld1 FROM tbl0";
|
||||
@@ -76,7 +76,7 @@ public class Db_qry_select_tst {
|
||||
// }
|
||||
// @Test public void Union() {
|
||||
// cmd.From_("tbl0").select("fld0").union_(qry2.from("tbl1").select("fld0"));
|
||||
// cmd.From_("tbl0").select("fld0").union_().from("tbl1").select("fld0"); // feasible, but will be bad later when trying to access Db_qry_select props
|
||||
// cmd.From_("tbl0").select("fld0").union_().from("tbl1").select("fld0"); // feasible, but will be bad later when trying to access Db_qry__select_cmd props
|
||||
// expd = "SELECT fld0 FROM tbl0 UNION SELECT fld0 FROM tbl1";
|
||||
// Tfds.Eq(cmd.XtoStr(), expd);
|
||||
// }
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
try {return engine.New_rdr_by_obj(stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.err_(e, "select failed: sql={0}", sql);}
|
||||
}
|
||||
public Object Exec_select_val() {
|
||||
try {Object rv = Db_qry_select.Rdr_to_val(engine.New_rdr(stmt.executeQuery(), sql)); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql);}
|
||||
try {Object rv = Db_qry__select_cmd.Rdr_to_val(engine.New_rdr(stmt.executeQuery(), sql)); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql);}
|
||||
}
|
||||
public Db_stmt Clear() {
|
||||
val_idx = 0;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statemen
|
||||
}
|
||||
public Db_rdr Exec_select_as_rdr() {throw Err_.not_implemented_();}
|
||||
public Object Exec_select_val() {
|
||||
try {Object rv = Db_qry_select.Rdr_to_val(this.Exec_select()); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql_orig);}
|
||||
try {Object rv = Db_qry__select_cmd.Rdr_to_val(this.Exec_select()); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql_orig);}
|
||||
}
|
||||
public Db_stmt Clear() {
|
||||
args.Clear();
|
||||
@@ -136,21 +136,41 @@ public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statemen
|
||||
public Db_stmt Parse(Db_qry qry, String sql_str) {
|
||||
this.qry = qry;
|
||||
this.sql_orig = sql_str;
|
||||
int arg_idx = 0;
|
||||
byte[] src = Bry_.new_utf8_(sql_str);
|
||||
int pos_prv = 0;
|
||||
Init_fmtr(tmp_bfr, tmp_fmtr, sql_str);
|
||||
return this;
|
||||
}
|
||||
private static void Init_fmtr(Bry_bfr tmp_bfr, Bry_fmtr tmp_fmtr, String sql_str) {
|
||||
byte[] sql_bry = Bry_.new_utf8_(sql_str);
|
||||
int arg_idx = 0; int pos_prv = 0;
|
||||
tmp_bfr.Clear();
|
||||
while (true) {
|
||||
int pos_cur = Bry_finder.Find_fwd(src, Byte_ascii.Question, pos_prv);
|
||||
if (pos_cur == Bry_.NotFound) break;
|
||||
tmp_bfr.Add_mid(src, pos_prv, pos_cur);
|
||||
int pos_cur = Bry_finder.Find_fwd(sql_bry, Byte_ascii.Question, pos_prv); if (pos_cur == Bry_.NotFound) break;
|
||||
tmp_bfr.Add_mid(sql_bry, pos_prv, pos_cur);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Tilde).Add_byte(Byte_ascii.Curly_bgn);
|
||||
tmp_bfr.Add_int_variable(arg_idx++);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Curly_end);
|
||||
pos_prv = pos_cur + 1;
|
||||
}
|
||||
tmp_bfr.Add_mid(src, pos_prv, src.length);
|
||||
tmp_bfr.Add_mid(sql_bry, pos_prv, sql_bry.length);
|
||||
tmp_fmtr.Fmt_(tmp_bfr.Xto_bry_and_clear());
|
||||
return this;
|
||||
}
|
||||
public static String Xto_str(Bry_bfr tmp_bfr, Bry_fmtr tmp_fmtr, String sql_str, ListAdp args) {
|
||||
Init_fmtr(tmp_bfr, tmp_fmtr, sql_str);
|
||||
Object[] ary = args.Xto_obj_ary();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Object obj = ary[i];
|
||||
String str = "";
|
||||
if (obj == null)
|
||||
str = "NULL";
|
||||
else {
|
||||
str = Object_.Xto_str_strict_or_null(obj);
|
||||
if (ClassAdp_.Eq(obj.getClass(), String_.Cls_ref_type))
|
||||
str = "'" + String_.Replace(str, "'", "''") + "'";
|
||||
}
|
||||
ary[i] = str;
|
||||
}
|
||||
tmp_fmtr.Bld_bfr_many(tmp_bfr, ary);
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
case Db_qry_.Tid_delete: return Bld_qry_delete((Db_qry_delete)cmd);
|
||||
case Db_qry_.Tid_update: return Bld_qry_update((Db_qry_update)cmd);
|
||||
case Db_qry_.Tid_select_in_tbl:
|
||||
case Db_qry_.Tid_select: return Bld_qry_select((Db_qry_select)cmd);
|
||||
case Db_qry_.Tid_select: return Bld_qry_select((Db_qry__select_cmd)cmd);
|
||||
case Db_qry_.Tid_sql: return ((Db_qry_sql)cmd).Xto_sql();
|
||||
default: throw Err_.unhandled(cmd.Tid());
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
Bld_where(sb, cmd.Where());
|
||||
return sb.Xto_str_and_clear();
|
||||
}
|
||||
private String Bld_qry_select(Db_qry_select cmd) {
|
||||
private String Bld_qry_select(Db_qry__select_cmd cmd) {
|
||||
sb.Add("SELECT ");
|
||||
if (cmd.Cols().Distinct()) sb.Add("DISTINCT ");
|
||||
Sql_select_fld_list flds = cmd.Cols().Flds();
|
||||
@@ -118,7 +118,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
}
|
||||
}
|
||||
private void Bld_select_limit(String_bldr sb, int limit) {
|
||||
if (limit == Db_qry_select.Limit_disabled) return;
|
||||
if (limit == Db_qry__select_cmd.Limit_disabled) return;
|
||||
sb.Add(" LIMIT ").Add(limit);
|
||||
}
|
||||
private void Bld_clause_from(String_bldr sb, Sql_from from) {
|
||||
@@ -197,6 +197,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
this.Bld_where_val(sb, crt);
|
||||
}
|
||||
public void Bld_where_val(String_bldr sb, Criteria crt) {
|
||||
if (crt == null) return; // handle empty crt; EX: SELECT * FROM tbl;
|
||||
Criteria_bool_base crt_bool = Criteria_bool_base.as_(crt);
|
||||
if (crt_bool != null) {
|
||||
sb.Add("(");
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.dbs.utls; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
public class PoolIds {
|
||||
public int FetchNext(Db_conn conn, String url) {
|
||||
Db_qry_select cmd = Db_qry_.select_().From_(Tbl_Name).Where_(Db_crt_.eq_(Fld_id_path, url));
|
||||
Db_qry__select_cmd cmd = Db_qry_.select_().From_(Tbl_Name).Where_(Db_crt_.eq_(Fld_id_path, url));
|
||||
int rv = 0;//boolean isNew = true;
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
try {
|
||||
|
||||
@@ -112,7 +112,7 @@ class CrudOpsFxt {
|
||||
this.Init();
|
||||
String val = "Ω";
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Arg_("id", 3).Arg_obj_type_("name", val, Db_val_type.Tid_nvarchar));
|
||||
Db_qry_select select = Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("id", 3));
|
||||
Db_qry__select_cmd select = Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("id", 3));
|
||||
Tfds.Eq(val, ExecRdr_val(select));
|
||||
|
||||
fx.tst_ExecDml(1, Db_qry_.update_("dbs_crud_ops", Db_crt_.Wildcard).Arg_obj_type_("name", val + "a", Db_val_type.Tid_nvarchar));
|
||||
@@ -125,5 +125,5 @@ class CrudOpsFxt {
|
||||
Tfds.Eq(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("id", 3))));
|
||||
Tfds.Eq(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("name", "\\"))));
|
||||
}
|
||||
String ExecRdr_val(Db_qry_select select) {return (String)select.ExecRdr_val(fx.Conn());}
|
||||
String ExecRdr_val(Db_qry__select_cmd select) {return (String)select.ExecRdr_val(fx.Conn());}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class GroupBys_base_tst {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Arg_("key1", "a").Arg_("val_int", 1));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Arg_("key1", "a").Arg_("val_int", 2));
|
||||
|
||||
Db_qry_select qry = Db_qry_.select_().From_("dbs_group_bys")
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1")
|
||||
.GroupBy_("key1");
|
||||
int expd = min ? 1 : 2;
|
||||
|
||||
@@ -35,10 +35,10 @@ public abstract class InsertIntos_base_tst {
|
||||
(Db_qry_.insert_("dbs_insert_intos")
|
||||
.Cols_("key1", "val_int")
|
||||
.Select_
|
||||
( Db_qry_select.new_().Cols_("key1", "val_int").From_("dbs_group_bys")
|
||||
( Db_qry__select_cmd.new_().Cols_("key1", "val_int").From_("dbs_group_bys")
|
||||
)
|
||||
);
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry_select.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry__select_cmd.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
}
|
||||
@@ -50,10 +50,10 @@ public abstract class InsertIntos_base_tst {
|
||||
(Db_qry_.insert_("dbs_insert_intos")
|
||||
.Cols_("key1", "val_int")
|
||||
.Select_
|
||||
( Db_qry_select.new_().Cols_("key1").Cols_groupBy_sum("val_int", "val_int_func")
|
||||
( Db_qry__select_cmd.new_().Cols_("key1").Cols_groupBy_sum("val_int", "val_int_func")
|
||||
.From_("dbs_group_bys").GroupBy_("key1")
|
||||
));
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry_select.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry__select_cmd.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "val_int", 3);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class Joins_base_tst {
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_crud_ops").Arg_("id", 1).Arg_("name", "you"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_join1").Arg_("join_id", 0).Arg_("join_data", "data0"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_join1").Arg_("join_id", 1).Arg_("join_data", "data1"));
|
||||
Db_qry_select select = Db_qry_select.new_().From_("dbs_crud_ops").Join_("dbs_join1", "j1", Sql_join_itm.new_("join_id", "dbs_crud_ops", "id")).Cols_("id", "name", "join_data");
|
||||
Db_qry__select_cmd select = Db_qry__select_cmd.new_().From_("dbs_crud_ops").Join_("dbs_join1", "j1", Sql_join_itm.new_("join_id", "dbs_crud_ops", "id")).Cols_("id", "name", "join_data");
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(select);
|
||||
GfoNde table = GfoNde_.rdr_(rdr);
|
||||
|
||||
@@ -29,11 +29,11 @@ public abstract class OrderBys_base_tst {
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 1).Arg_("name", "you"));
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 0).Arg_("name", "me"));
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 1, "you");
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_RowAry(0, 1, "you");
|
||||
fx.tst_RowAry(1, 0, "me");
|
||||
}
|
||||
@@ -41,11 +41,11 @@ public abstract class OrderBys_base_tst {
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 0).Arg_("name", "me"));
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 0).Arg_("name", "you"));
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 0, "you");
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 0, "you");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user