mirror of https://github.com/gnosygnu/xowa
parent
de67253a9c
commit
baaef32df2
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>100_core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
Binary file not shown.
@ -1,60 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
public class KeyValHash {
|
||||
private Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Count() {return hash.Count();}
|
||||
public KeyValHash Clear() {hash.Clear(); return this;}
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
public KeyVal Get_at(int i) {return (KeyVal)hash.Get_at(i);}
|
||||
public Object FetchValOr(String key, Object or) {KeyVal rv = FetchOrNull(key); return rv == null ? or : rv.Val();}
|
||||
public Object FetchValOrNull(String key) {return FetchValOr(key, null);}
|
||||
public Object FetchValOrFail(String key) {return KeyVal_.as_(hash.Get_by_or_fail(key)).Val();}
|
||||
public KeyValHash Add(KeyVal kv) {hash.Add(kv.Key(), kv); return this;}
|
||||
public KeyValHash Add(String key, Object val) {hash.Add(key, KeyVal_.new_(key, val)); return this;}
|
||||
public KeyValHash Add_if_dupe_use_nth(String key, Object val) {hash.Add_if_dupe_use_nth(key, KeyVal_.new_(key, val)); return this;}
|
||||
public void Del(String key) {hash.Del(key);}
|
||||
public KeyVal[] Xto_bry() {
|
||||
KeyVal[] rv = new KeyVal[this.Count()];
|
||||
for (int i = 0; i < rv.length; i++)
|
||||
rv[i] = this.Get_at(i);
|
||||
return rv;
|
||||
}
|
||||
public static KeyValHash new_() {return new KeyValHash();} protected KeyValHash() {}
|
||||
public static KeyValHash new_by_ary(KeyVal[] ary) {
|
||||
int ary_len = ary.length;
|
||||
KeyValHash rv = new KeyValHash();
|
||||
for (int i = 0; i < ary_len; i++)
|
||||
rv.Add(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public KeyVal FetchOrNull(String key) {return KeyVal_.as_(hash.Get_by(key));}
|
||||
public static KeyValHash strAry_(String[] ary) {// needed for consoleLine
|
||||
int aryLen = Array_.Len(ary); if (aryLen % 2 != 0) throw Err_.new_wo_type("array length must be divisible by 2", "aryLen", aryLen, "ary", String_.Concat_lines_crlf(ary));
|
||||
KeyValHash rv = new KeyValHash();
|
||||
String key = null;
|
||||
for (int i = 0; i < aryLen; i++) {
|
||||
if (i % 2 == 0)
|
||||
key = ary[i];
|
||||
else
|
||||
rv.Add(key, ary[i]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final KeyValHash Empty = new KeyValHash();
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
import gplx.core.strings.*;
|
||||
public class KeyValList {//20101217
|
||||
public int Count() {return list.Count();} List_adp list = List_adp_.new_();
|
||||
public void Clear() {list.Clear();}
|
||||
public KeyVal GetAt(int i) {return (KeyVal)list.Get_at(i);}
|
||||
public KeyValList Add(String key, Object val) {list.Add(KeyVal_.new_(key, val)); return this;}
|
||||
public KeyVal[] Xto_bry() {return (KeyVal[])list.To_ary(KeyVal.class);}
|
||||
public String To_str() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int i = 0; i < list.Count(); i++) {
|
||||
KeyVal kv = (KeyVal)list.Get_at(i);
|
||||
sb.Add_spr_unless_first(kv.Key(), " ", i);
|
||||
sb.Add("=").Add(kv.Val_to_str_or_empty());
|
||||
}
|
||||
return sb.To_str();
|
||||
}
|
||||
public static KeyValList args_(String key, Object val) {return new KeyValList().Add(key, val);}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
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;
|
||||
public class Keyval_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Count() {return hash.Count();}
|
||||
public Keyval_hash Clear() {hash.Clear(); return this;}
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
public Keyval Get_at(int i) {return (Keyval)hash.Get_at(i);}
|
||||
public Object Get_val_or(String key, Object or) {Keyval rv = Get_kvp_or_null(key); return rv == null ? or : rv.Val();}
|
||||
public Object Get_val_or_null(String key) {return Get_val_or(key, null);}
|
||||
public Object Get_val_or_fail(String key) {return Keyval_.as_(hash.Get_by_or_fail(key)).Val();}
|
||||
public String Get_val_as_str_or_fail(String key) {return (String)Get_val_or_fail(key);}
|
||||
public Keyval Get_kvp_or_null(String key) {return Keyval_.as_(hash.Get_by(key));}
|
||||
public Keyval_hash Add(Keyval kv) {hash.Add(kv.Key(), kv); return this;}
|
||||
public Keyval_hash Add(String key, Object val) {hash.Add(key, Keyval_.new_(key, val)); return this;}
|
||||
public Keyval_hash Add_if_dupe_use_nth(String key, Object val) {hash.Add_if_dupe_use_nth(key, Keyval_.new_(key, val)); return this;}
|
||||
public void Del(String key) {hash.Del(key);}
|
||||
public Keyval[] To_ary() {
|
||||
int len = this.Count();
|
||||
Keyval[] rv = new Keyval[len];
|
||||
for (int i = 0; i < len; ++i)
|
||||
rv[i] = this.Get_at(i);
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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;
|
||||
public class Keyval_list {
|
||||
public int Count() {return list.Count();} private final List_adp list = List_adp_.new_();
|
||||
public void Clear() {list.Clear();}
|
||||
public Keyval Get_at(int i) {return (Keyval)list.Get_at(i);}
|
||||
public Keyval_list Add(String key, Object val) {list.Add(Keyval_.new_(key, val)); return this;}
|
||||
public Keyval[] To_ary() {return (Keyval[])list.To_ary(Keyval.class);}
|
||||
public String To_str() {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Keyval kv = (Keyval)list.Get_at(i);
|
||||
if (i == 0) bfr.Add_byte_space();
|
||||
bfr.Add_str_u8(kv.Key()).Add_byte_eq().Add_str_u8(kv.Val_to_str_or_empty());
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public static Keyval_list New_with_one(String key, Object val) {return new Keyval_list().Add(key, val);}
|
||||
}
|
@ -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.core.brys.fmts; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
|
||||
import org.junit.*;
|
||||
public class Bry_keys_parser_tst {
|
||||
private final Bry_keys_parser_fxt fxt = new Bry_keys_parser_fxt();
|
||||
@Test public void None() {fxt.Test("a");}
|
||||
@Test public void One() {fxt.Test("~{a}" , "a");}
|
||||
@Test public void Many() {fxt.Test("~{a}b~{c}d~{e}" , "a", "c", "e");}
|
||||
@Test public void Dupe() {fxt.Test("~{a}b~{a}" , "a");}
|
||||
}
|
||||
class Bry_keys_parser_fxt {
|
||||
public void Test(String fmt, String... expd) {
|
||||
Tfds.Eq_ary(expd, String_.Ary(Bry_fmt_parser_.Parse_keys(Bry_.new_u8(fmt))));
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>110_gfml</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>140_dbs</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
||||
/*
|
||||
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_attach_itm {
|
||||
public Db_attach_itm(String key, Io_url url) {
|
||||
this.Key = key; this.Url = url;
|
||||
}
|
||||
public Db_attach_itm(String key, Db_conn conn) {
|
||||
this.Key = key; this.Url = gplx.dbs.engines.sqlite.Sqlite_conn_info.To_url(conn);
|
||||
}
|
||||
public final String Key;
|
||||
public final Io_url Url;
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
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.*;
|
||||
import gplx.dbs.sqls.*; import gplx.dbs.sqls.itms.*;
|
||||
public class Db_attach_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public final List_adp attached_dbs_list = List_adp_.new_();
|
||||
public String Attached_sql() {return attached_sql;} private String attached_sql; // TEST
|
||||
private Db_conn main_conn; private Io_url main_conn_url;
|
||||
public Db_attach_mgr() {}
|
||||
public Db_attach_mgr(Db_conn main_conn, Db_attach_itm... itms_ary) {
|
||||
this.Main_conn_(main_conn);
|
||||
this.Init(itms_ary);
|
||||
}
|
||||
public Db_attach_mgr Init(Db_attach_itm... itms_ary) {
|
||||
hash.Clear();
|
||||
int itms_len = itms_ary.length;
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Db_attach_itm itm = itms_ary[i];
|
||||
hash.Add(itm.Key, itm);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Db_attach_mgr Main_conn_(Db_conn conn) {
|
||||
this.main_conn = conn; this.main_conn_url = Db_conn_info_.To_url(conn.Conn_info());
|
||||
return this;
|
||||
}
|
||||
public void Attach() {
|
||||
int len = attached_dbs_list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_attach_itm itm = (Db_attach_itm)attached_dbs_list.Get_at(i);
|
||||
main_conn.Env_db_attach(itm.Key, itm.Url);
|
||||
}
|
||||
}
|
||||
public void Detach() {
|
||||
int len = attached_dbs_list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_attach_itm itm = (Db_attach_itm)attached_dbs_list.Get_at(i);
|
||||
main_conn.Env_db_detach(itm.Key);
|
||||
}
|
||||
attached_dbs_list.Clear(); // clear list so multiple detachs don't fail
|
||||
}
|
||||
public String List__to_str() {
|
||||
String rv = "";
|
||||
int len = attached_dbs_list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_attach_itm itm = (Db_attach_itm)attached_dbs_list.Get_at(i);
|
||||
rv += itm.Key + ";";
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public String Resolve_sql(String sql) {
|
||||
attached_dbs_list.Clear();
|
||||
int hash_len = hash.Count();
|
||||
for (int i = 0; i < hash_len; ++i) {
|
||||
Db_attach_itm attach_itm = (Db_attach_itm)hash.Get_at(i);
|
||||
String tkn = "<" + attach_itm.Key + ">";
|
||||
if (String_.Has(sql, tkn)) {
|
||||
Io_url attach_url = attach_itm.Url;
|
||||
String repl = "";
|
||||
if (!attach_url.Eq(main_conn_url)) {
|
||||
repl = attach_itm.Key + ".";
|
||||
attached_dbs_list.Add(attach_itm);
|
||||
}
|
||||
sql = String_.Replace(sql, tkn, repl);
|
||||
}
|
||||
}
|
||||
attached_sql = sql;
|
||||
return sql;
|
||||
}
|
||||
public Db_stmt Make_stmt_and_attach(Db_qry qry, gplx.dbs.sqls.itms.Sql_from_clause from_itm) {
|
||||
attached_dbs_list.Clear();
|
||||
Sql_qry_wtr sql_wtr = main_conn.Engine().Sql_wtr();
|
||||
List_adp from_tbls = from_itm.Tbls;
|
||||
int from_tbls_len = from_tbls.Count();
|
||||
for (int i = 0; i < from_tbls_len; ++i) {
|
||||
Sql_tbl_itm from_tbl = (Sql_tbl_itm)from_tbls.Get_at(i);
|
||||
String from_tbl_db = from_tbl.Db;
|
||||
if (String_.Eq(Sql_tbl_itm.Db__null, from_tbl_db)) continue; // tbl does not have db defined; only "tbl" not "db.tbl"; skip
|
||||
Db_attach_itm attach_itm = (Db_attach_itm)hash.Get_by(from_tbl_db); if (attach_itm == null) throw Err_.new_("dbs", "qry defines an unknown database for attach_wkr", "from_tbl_db", from_tbl_db, "sql", qry.To_sql__exec(sql_wtr));
|
||||
if (attach_itm.Url.Eq(main_conn_url)) // attach_db same as conn; blank db, so "tbl", not "db.tbl"
|
||||
from_tbl.Db_enabled = false;
|
||||
else
|
||||
attached_dbs_list.Add(attach_itm);
|
||||
}
|
||||
attached_sql = sql_wtr.To_sql_str(qry, true);
|
||||
this.Attach();
|
||||
for (int i = 0; i < from_tbls_len; ++i) { // reverse blanking from above
|
||||
Sql_tbl_itm from_tbl = (Sql_tbl_itm)from_tbls.Get_at(i);
|
||||
from_tbl.Db_enabled = true;
|
||||
}
|
||||
return main_conn.Stmt_sql(attached_sql);
|
||||
}
|
||||
public Db_attach_mgr Exec_sql_w_msg(String msg, String sql, Object... args) {
|
||||
Gfo_usr_dlg_.Instance.Plog_many("", "", msg);
|
||||
Exec_sql(sql, args);
|
||||
return this;
|
||||
}
|
||||
public void Exec_sql(String sql, Object... args) {
|
||||
String attach_sql = String_.Format(Resolve_sql(sql), args);
|
||||
this.Attach();
|
||||
try {main_conn.Exec_sql(attach_sql);}
|
||||
finally {this.Detach();}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
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.*;
|
||||
import org.junit.*; import gplx.dbs.qrys.*;
|
||||
public class Db_attach_mgr__tst {
|
||||
private final Db_attach_mgr__fxt fxt = new Db_attach_mgr__fxt();
|
||||
@Test public void Basic() {
|
||||
Db_qry__select_cmd qry = Db_qry_.select_()
|
||||
.Cols_w_tbl_("t1", "fld_1")
|
||||
.Cols_w_tbl_("t2", "fld_2")
|
||||
.Cols_w_tbl_("t3", "fld_3")
|
||||
.From_("db_1", "tbl_1", "t1")
|
||||
.Join_("db_2", "tbl_2", "t2", Db_qry_.New_join__same("t1", "fld_2"))
|
||||
.Join_("db_3", "tbl_3", "t3", Db_qry_.New_join__same("t1", "fld_3"))
|
||||
.Join_( "tbl_4", "t4", Db_qry_.New_join__same("t1", "fld_4"))
|
||||
;
|
||||
fxt.Init("db_2", fxt.Make__itm("db_1"), fxt.Make__itm("db_2"), fxt.Make__itm("db_3"));
|
||||
fxt.Test__make_stmt_and_attach(qry
|
||||
, "SELECT t1.fld_1, t2.fld_2, t3.fld_3 "
|
||||
+ "FROM db_1.tbl_1 t1 "
|
||||
+ "INNER JOIN tbl_2 t2 ON t1.fld_2 = t2.fld_2 " // NOTE: curr is db_2 so do not prefix tbl_2 with db_2; fails if "db_2.tbl_2"
|
||||
+ "INNER JOIN db_3.tbl_3 t3 ON t1.fld_3 = t3.fld_3 "
|
||||
+ "INNER JOIN tbl_4 t4 ON t1.fld_4 = t4.fld_4"
|
||||
, String_.Ary("db_1", "db_3") // NOTE: no "db_2"
|
||||
);
|
||||
}
|
||||
}
|
||||
class Db_attach_mgr__fxt {
|
||||
private Db_attach_mgr mgr;
|
||||
public Db_attach_itm Make__itm(String key) {return new Db_attach_itm(key, Io_url_.mem_fil_("mem/" + key));}
|
||||
public Db_conn Make__conn(String key) {return Db_conn_pool.Instance.Get_or_new__mem(key);}
|
||||
public void Init(String conn_key, Db_attach_itm... ary) {
|
||||
Db_conn conn = Make__conn(conn_key);
|
||||
mgr = new Db_attach_mgr(conn, ary);
|
||||
}
|
||||
public void Test__make_stmt_and_attach(Db_qry__select_cmd qry, String expd_sql, String[] expd_dbs) {
|
||||
mgr.Make_stmt_and_attach(qry, qry.From());
|
||||
Tfds.Eq_str(expd_sql, mgr.Attached_sql());
|
||||
Tfds.Eq_ary_str(expd_dbs, To_key_ary(mgr.attached_dbs_list));
|
||||
}
|
||||
private static String[] To_key_ary(List_adp attach_dbs_list) {
|
||||
int rv_len = attach_dbs_list.Count();
|
||||
String[] rv = new String[rv_len];
|
||||
for (int i = 0; i < rv_len; ++i) {
|
||||
Db_attach_itm itm = (Db_attach_itm)attach_dbs_list.Get_at(i);
|
||||
rv[i] = itm.Key;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
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_null implements gplx.core.brys.Bfr_arg {
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {bfr.Add_str_a7(Null_str);}
|
||||
@Override public String toString() {return Null_str;}
|
||||
public static final String Null_str = "NULL";
|
||||
public static final Db_null Instance = new Db_null(); Db_null() {}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue