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-04-27 00:27:52 -04:00
parent 299e19d455
commit f4b95f5ce6
126 changed files with 1840 additions and 671 deletions

View File

@@ -25,14 +25,16 @@ public class Db_attach_rdr {
Sqlite_conn_info conn_info = (Sqlite_conn_info)conn.Conn_info();
this.diff_db = !String_.Eq(conn_info.Url().Raw(), attach_url.Raw());
}
public Db_rdr Exec_as_rdr(String sql) {
public void Attach() {
try {
if (diff_db) conn.Env_db_attach(attach_name, attach_url);
} catch (Exception e) {Err_.Noop(e); Gfo_usr_dlg_.I.Warn_many("", "", "db:failed to attach db; name=~{0} url=~{1}", attach_name, attach_url.Raw());}
} catch (Exception e) {Err_.Noop(e); Gfo_usr_dlg_.I.Warn_many("", "", "db:failed to attach db; name=~{0} url=~{1}", attach_name, attach_url.Raw());}
}
public Db_rdr Exec_as_rdr(String sql) {
sql = String_.Replace(sql, "<attach_db>", diff_db ? attach_name + "." : ""); // replace <attach> with either "attach_db." or "";
return conn.Exec_sql_as_rdr2(sql);
}
public void Rls() {
public void Detach() {
if (diff_db) conn.Env_db_detach(attach_name);
}
}

View File

@@ -60,6 +60,7 @@ public class Db_cfg_tbl implements RlsAble {
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_grp, fld_key);
stmt_update.Clear().Val_str(fld_val, val).Crt_str(fld_grp, grp).Crt_str(fld_key, key).Exec_update();
}
public void Upsert_yn (String grp, String key, boolean val) {Upsert_str(grp, key, val ? "y" : "n");}
public void Upsert_int (String grp, String key, int val) {Upsert_str(grp, key, Int_.Xto_str(val));}
public void Upsert_str (String grp, String key, String val) {
String cur_val = this.Select_str_or(grp, key, null);

View File

@@ -40,7 +40,7 @@ class Schema_update_mgr_fxt {
public void Test_exec_n(Schema_update_cmd cmd) {Test_exec(cmd, Bool_.N);}
private void Test_exec(Schema_update_cmd cmd, boolean expd) {
update_mgr.Add(cmd);
update_mgr.Update(db_mgr, Db_conn_.Empty);
update_mgr.Update(db_mgr, Db_conn_.Noop);
Tfds.Eq(expd, cmd.Exec_is_done());
}
}