Inconsistencies in model names in queries
Bharat Mediratta <[email protected]> Sat, 20 Apr 2013 12:11:52 -0700
| Newsgroups | gmane.comp.web.gallery.devel |
|---|---|
| Message-ID | <CAESa+_mteFkDcy7vUtbg2unedC=c4VhBZFvMtYLnNOWaBhraQQ@mail.gmail.com> |
--===============3823959138041948768==
Content-Type: multipart/alternative; boundary=047d7bdca3521eade504dacf9ea5
--047d7bdca3521eade504dacf9ea5
Content-Type: text/plain; charset=ISO-8859-1
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
--047d7bdca3521eade504dacf9ea5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div style>Shad,</div><div style><br></div><div style>I=
9;m trying to plumb a line through the test code which means getting all th=
e installer code working properly when you call Module::install("galle=
ry"). =A0Note that this is different from a fresh install because the =
fresh install just unpacks pre-prepared SQL. =A0So eventually we call Acces=
s::_update_access_view_cache which bombs around line 553 when it's tryi=
ng to find all albums that don't inherit access permission. =A0I can ge=
t the query to work if I change it to this:</div>
<div style><br></div><div style><div><font face=3D"courier new, monospace">=
=A0 =A0545 =A0 =A0 =A0$query =3D ORM::factory("AccessIntent") =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0=A0</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0546 =A0 =A0 =A0 =A0->s=
elect("accessintent.$field", "items.left_ptr", "it=
ems.right_ptr", "<a href=3D"http://items.id">items.id</a>") =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0547 =A0 =A0 =A0 =A0->j=
oin("items")->on("<a href=3D"http://items.id">items.id</a=
>", "=3D", "accessintent.item_id") =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0548 =A0 =A0 =A0 =A0->w=
here("left_ptr", ">=3D", $item->left_ptr) =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0</font></div><div>
<font face=3D"courier new, monospace">=A0 =A0549 =A0 =A0 =A0 =A0->where(=
"right_ptr", "<=3D", $item->right_ptr) =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</f=
ont></div><div><font face=3D"courier new, monospace">=A0 =A0550 =A0 =A0 =A0=
=A0->where("type", "=3D", "album") =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0551 =A0 =A0 =A0 =A0->w=
here("accessintent.$field", "IS NOT", Access::INHERIT) =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0</font></div><div><f=
ont face=3D"courier new, monospace">=A0 =A0552 =A0 =A0 =A0 =A0->order_by=
("level", "DESC") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0=A0</font></div>
<div><font face=3D"courier new, monospace">=A0 =A0553 =A0 =A0 =A0 =A0->f=
ind_all(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0=A0</font></div><div><br></div></div><div style>
But what's frustrating about this is that we're mixing several diff=
erent forms here. =A0Line 545 has our camel cased model name. =A0Line 546 h=
as an intermediate form of the access intent table which is not camel cased=
, but is not pluralized. =A0Then the items table <i>is</i>=A0pluralized. =
=A0Same thing on line 547.</div>
<div style><br></div><div style>I haven't had time to dig into this, bu=
t my general feeling is that we're missing something and/or we've o=
utsmarted ourselves here. =A0In K2 there were only two forms - singular and=
plural and we'd always use the plural in database forms. =A0In K3 we h=
ave this 3rd form which doesn't make as much sense.</div>
<div style><br></div><div style>any thoughts on this? =A0I'll try to ci=
rcle back to it later today..</div><div style><br></div><div style>-Bharat<=
/div></div>
--047d7bdca3521eade504dacf9ea5--
--===============3823959138041948768==
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
--===============3823959138041948768==
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 ]
--===============3823959138041948768==--