Re: Inconsistencies in model names in queries
Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> Sun, 21 Apr 2013 02:01:40 +0200
| Newsgroups | gmane.comp.web.gallery.devel |
|---|---|
| Message-ID | <CA+z51A68NFWY4WMDJB_RcNYb5_BhMmAnpY8sLgGdvZRu-co6Jg@mail.gmail.com> |
--===============6108433573533282329== Content-Type: multipart/alternative; boundary=089e0115f20e24149a04dad3a82e --089e0115f20e24149a04dad3a82e Content-Type: text/plain; charset=UTF-8 Hey Bharat, About to head off to bed, and will take a closer look in the morn, but a couple quick thoughts... First, the names of database columns and tables have not changed at all. So, in principle, I think it should still be an access_intent in access_intents. Second, the model class (and filename) has, to AccessIntent. This what the ORM factory likes, but that should be it (I think). I put the ORM override in there to ensure that AccessIntent got translated as access_intent - if it isn't working, perhaps it's in need of debugging? Third, queries like that look like they're begging for a defined relationship (ORM, not OKCupid), which should remove the need to make tricky join arguments. Sorry for the quick response! Take care, Shad Sent from my Swiss Army Phone On Apr 20, 2013 9:13 PM, "Bharat Mediratta" <[email protected]> wrote: > Shad, > > I'm trying to plumb a line through the test code which means getting all > the installer code working properly when you call > Module::install("gallery"). Note that this is different from a fresh > install because the fresh install just unpacks pre-prepared SQL. So > eventually we call Access::_update_access_view_cache which bombs around > line 553 when it's trying to find all albums that don't inherit access > permission. I can get the query to work if I change it to this: > > 545 $query = ORM::factory("AccessIntent") > > 546 ->select("accessintent.$field", "items.left_ptr", > "items.right_ptr", "items.id") > 547 ->join("items")->on("items.id", "=", > "accessintent.item_id") > > 548 ->where("left_ptr", ">=", $item->left_ptr) > > 549 ->where("right_ptr", "<=", $item->right_ptr) > > 550 ->where("type", "=", "album") > > 551 ->where("accessintent.$field", "IS NOT", Access::INHERIT) > > 552 ->order_by("level", "DESC") > > 553 ->find_all(); > > > But what's frustrating about this is that we're mixing several different > forms here. Line 545 has our camel cased model name. Line 546 has an > intermediate form of the access intent table which is not camel cased, but > is not pluralized. Then the items table *is* pluralized. Same thing on > line 547. > > I haven't had time to dig into this, but my general feeling is that we're > missing something and/or we've outsmarted ourselves here. In K2 there were > only two forms - singular and plural and we'd always use the plural in > database forms. In K3 we have this 3rd form which doesn't make as much > sense. > > any thoughts on this? I'll try to circle back to it later today.. > > -Bharat > > > ------------------------------------------------------------------------------ > Precog is a next-generation analytics platform capable of advanced > analytics on semi-structured data. The platform includes APIs for building > apps and a phenomenal toolset for data science. Developers can use > our toolset for easy data analysis & visualization. Get a free account! > http://www2.precog.com/precogplatform/slashdotnewsletter > __[ g a l l e r y - d e v e l ]_________________________ > > [ list info/archive --> http://gallery.sf.net/lists.php ] > [ gallery info/FAQ/download --> http://gallery.sf.net ] > --089e0115f20e24149a04dad3a82e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <p>Hey Bharat,</p> <p>About to head off to bed, and will take a closer look in the morn, but a= couple quick thoughts...</p> <p>First, the names of database columns and tables have not changed at all.= =C2=A0 So, in principle, I think it should still be an access_intent in acc= ess_intents.</p> <p>Second, the model class (and filename) has, to AccessIntent.=C2=A0 This = what the ORM factory likes, but that should be it (I think).=C2=A0 I put th= e ORM override in there to ensure that AccessIntent got translated as acces= s_intent - if it isn't working, perhaps it's in need of debugging?<= /p> <p>Third, queries like that look like they're begging for a defined rel= ationship (ORM, not OKCupid), which should remove the need to make tricky j= oin arguments.</p> <p>Sorry for the quick response!</p> <p>Take care,<br> Shad</p> <p>Sent from my Swiss Army Phone</p> <div class=3D"gmail_quote">On Apr 20, 2013 9:13 PM, "Bharat Mediratta&= quot; <<a href=3D"mailto:[email protected]">[email protected]</a>> = wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"m= argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div dir=3D"ltr"><div>Shad,</div><div><br></div><div>I'm trying to plum= b a line through the test code which means getting all the installer code w= orking properly when you call Module::install("gallery"). =C2=A0N= ote that this is different from a fresh install because the fresh install j= ust unpacks pre-prepared SQL. =C2=A0So eventually we call Access::_update_a= ccess_view_cache which bombs around line 553 when it's trying to find a= ll albums that don't inherit access permission. =C2=A0I can get the que= ry to work if I change it to this:</div> <div><br></div><div><div><font face=3D"courier new, monospace">=C2=A0 =C2= =A0545 =C2=A0 =C2=A0 =C2=A0$query =3D ORM::factory("AccessIntent"= ) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0=C2=A0</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0546 =C2=A0 =C2=A0 = =C2=A0 =C2=A0->select("accessintent.$field", "items.left_= ptr", "items.right_ptr", "<a href=3D"http://items.id" t= arget=3D"_blank">items.id</a>") =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0547 =C2=A0 =C2=A0 = =C2=A0 =C2=A0->join("items")->on("<a href=3D"http://it= ems.id" target=3D"_blank">items.id</a>", "=3D", "access= intent.item_id") =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0548 =C2=A0 =C2=A0 = =C2=A0 =C2=A0->where("left_ptr", ">=3D", $item-&g= t;left_ptr) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</font= ></div><div> <font face=3D"courier new, monospace">=C2=A0 =C2=A0549 =C2=A0 =C2=A0 =C2=A0= =C2=A0->where("right_ptr", "<=3D", $item->rig= ht_ptr) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</font></div><di= v><font face=3D"courier new, monospace">=C2=A0 =C2=A0550 =C2=A0 =C2=A0 =C2= =A0 =C2=A0->where("type", "=3D", "album") = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0551 =C2=A0 =C2=A0 = =C2=A0 =C2=A0->where("accessintent.$field", "IS NOT"= , Access::INHERIT) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0=C2=A0</font></div><div><font face=3D"courier new, mono= space">=C2=A0 =C2=A0552 =C2=A0 =C2=A0 =C2=A0 =C2=A0->order_by("leve= l", "DESC") =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</font></d= iv> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0553 =C2=A0 =C2=A0 = =C2=A0 =C2=A0->find_all(); =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</font></div><div><br></div></d= iv><div> But what's frustrating about this is that we're mixing several diff= erent forms here. =C2=A0Line 545 has our camel cased model name. =C2=A0Line= 546 has an intermediate form of the access intent table which is not camel= cased, but is not pluralized. =C2=A0Then the items table <i>is</i>=C2=A0pl= uralized. =C2=A0Same thing on line 547.</div> <div><br></div><div>I haven't had time to dig into this, but my general= feeling is that we're missing something and/or we've outsmarted ou= rselves here. =C2=A0In K2 there were only two forms - singular and plural a= nd we'd always use the plural in database forms. =C2=A0In K3 we have th= is 3rd form which doesn't make as much sense.</div> <div><br></div><div>any thoughts on this? =C2=A0I'll try to circle back= to it later today..</div><div><br></div><div>-Bharat</div></div> <br>-----------------------------------------------------------------------= -------<br> Precog is a next-generation analytics platform capable of advanced<br> analytics on semi-structured data. The platform includes APIs for building<= br> apps and a phenomenal toolset for data science. Developers can use<br> our toolset for easy data analysis & visualization. Get a free account!= <br> <a href=3D"http://www2.precog.com/precogplatform/slashdotnewsletter" target= =3D"_blank">http://www2.precog.com/precogplatform/slashdotnewsletter</a><br= >__[ g a l l e r y - d e v e l ]_________________________<br> <br> [ list info/archive --> <a href=3D"http://gallery.sf.net/lists.php" targ= et=3D"_blank">http://gallery.sf.net/lists.php</a> ]<br> [ gallery info/FAQ/download --> <a href=3D"http://gallery.sf.net" target= =3D"_blank">http://gallery.sf.net</a> ]<br></blockquote></div> --089e0115f20e24149a04dad3a82e-- --===============6108433573533282329== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter --===============6108433573533282329== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline __[ g a l l e r y - d e v e l ]_________________________ [ list info/archive --> http://gallery.sf.net/lists.php ] [ gallery info/FAQ/download --> http://gallery.sf.net ] --===============6108433573533282329==--