Example #1
0
 public DbIns   INS(params object[] values)
 {
     if (in_Assertion == 0)
     {
         in_Assertion++;
         DbIns copyOfRet = new DbIns(Name, fields, values);
         DbIns recreated = new DbIns((Reach)(copyOfRet.smb()));
         ass(copyOfRet.sql().Equals(recreated.sql()));
         in_Assertion--;
     }
     return(new DbIns(Name, fields, values));
 }
Example #2
0
        internal DbIns(Reach smb)
        {
            init();
            //TBD
            Db    db        = new Db(new ctx().DbDrivers);
            DbIns ret       = null;
            Zone  bktFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "(", ")", "||:0"));
            Zone  strFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "\"", "\"", "||:1"));

            /*
             * string insstr = "Grid(\"prdrln\").sC(\"sbj, obj, vb, rul, steps, excerpt, trust\").INS(XXXX)";
             * insstr = insstr.Replace("XXXX", "Grid(\"prdrln p1, prdvrb pv1, prdrln p2, prdvrb pv2, kndrln sc, itmrln si, prdvrb pv, prdrul pr, itmrln oi, kndrln oc\", cd(\"p1.obj\").EQ(\"p2.sbj\")).sC(\"si.id, oi.id, pv.id, pr.id, 0, '', 0.5\").sR(XXXX).SLD");
             * insstr = insstr.Replace("XXXX", "cd(\"0\").EQ(Grid(\"prdrln prdrln\").sC(\"count(*)\").sR(cd(\"sbj\").EQ(\"si.id\"), cd(\"obj\").EQ(\"oi.id\"), cd(\"vb\").EQ(\"pr.vb\")).SLC ), XXXX");
             * insstr = bktFilter.on(insstr).text;
             * insstr = insstr.Replace("XXXX", "cd(\"0\").EQ(Grid(\"prdrln prdrln\").sC(\"count(*)\").sR(cd(\"sbj\").EQ(\"si.id\"), cd(\"obj\").EQ(\"oi.id\"), cd(\"vb\").EQ(\"pr.vb\")).SLC ), XXXX");
             */

            Reach gridDef = smb - bktFilter.on(smb);
            Reach ins     = gridDef.at(".INS(");

            if (ins.len == 0)
            {
                throw new Exception("DbIns Constructor: invalid symbolic Definition");
            }
            DbGrid res = db.Grid(smb.before(ins));

            smb = smb.after(ins).before(-1, ")");
            if (smb.startsWith("Grid("))
            {
                ret = res.INS(new DbSlc(smb));
            }
            else
            {
                Pile <string> val = new Pile <string>();
                while (smb.len > 0)
                {
                    if (smb.startsWith("ds("))
                    {
                        val.Push(db.ds(smb.after(1, "\"").before(1, "\""))); smb = smb.after(1, "),").Trim();
                    }
                    else
                    {
                        val.Push(smb.before(1, ",").Trim()); smb = smb.after(1, ",").Trim();
                    }
                }
                ret = res.INS(val.array());
            }
            into   = ret.into;
            fields = ret.fields.Clone(); //new Pile<string>(ret.fieldNames);
            values = ret.values;
            slc    = ret.slc;
        }