[web-devel] [Yesod][Persistent] FooIdEq,FooIdIn
Greg Weber
greg at gregweber.info
Mon Mar 21 04:47:42 CET 2011
Great effort!
That is a mammoth patch.
Could you use git add -p to create 2 commits- one with as much of
the refactoring as possible, and the other focusing on the additions?
Greg Weber
On Sun, Mar 20, 2011 at 7:02 PM, Aur Saraf <sonoflilit at gmail.com> wrote:
> On Tue, Mar 15, 2011 at 2:45 AM, Aur Saraf <sonoflilit at gmail.com> wrote:
> > Right now I'm having lots of trouble with the TH code generation. I'll
> > post my code once the first unit tests pass - a lot before it would
> > actually be useful - to see what you guys say about my methods. Also,
> > there's a lot of cleaning up - or at least restyling, but I like to
> > think it is cleaning up - of TH.hs, which is useful in general.
>
> At last, my first unit test passes. I have something to show.
>
> _join = do
> a <- insert $ Person "Aur" 12 Nothing
> b <- insert $ Person "Bar" 13 $ Just "Blue"
> c <- insert $ Pet a "Mazal" Cat
> d <- insert $ Pet b "Sasha" Dog
> pets <- selectList [PetOwner $ PersonNameEq "Hanners"] [] 0 0
> assertEmpty pets
> pets <- selectList [PetOwner $ PersonNameEq "Aur"] [] 0 0
> assertNotEmpty pets
> return ()
>
> "BEGIN"
> "INSERT INTO \"Person\"(\"name\",\"age\",\"color\") VALUES(?,?,?)"
> "SELECT last_insert_rowid()"
> "INSERT INTO \"Person\"(\"name\",\"age\",\"color\") VALUES(?,?,?)"
> "SELECT last_insert_rowid()"
> "INSERT INTO \"Pet\"(\"owner\",\"nick\",\"type\") VALUES(?,?,?)"
> "SELECT last_insert_rowid()"
> "INSERT INTO \"Pet\"(\"owner\",\"nick\",\"type\") VALUES(?,?,?)"
> "SELECT last_insert_rowid()"
> "SELECT \"Pet\".\"id\",\"Pet\".\"owner\",\"Pet\".\"nick\",\"Pet\".\"type\"
> FROM \"Pet\" INNER JOIN \"Person\" ON
> \"Person\".\"id\"=\"Pet\".\"owner\" WHERE \"Person\".\"name\"=?"
> "SELECT \"Pet\".\"id\",\"Pet\".\"owner\",\"Pet\".\"nick\",\"Pet\".\"type\"
> FROM \"Pet\" INNER JOIN \"Person\" ON
> \"Person\".\"id\"=\"Pet\".\"owner\" WHERE \"Person\".\"name\"=?"
> "COMMIT"
> "INSERT INTO \"Person\"(\"name\",\"age\",\"color\") VALUES(?,?,?) RETURNING
> id"
> "INSERT INTO \"Person\"(\"name\",\"age\",\"color\") VALUES(?,?,?) RETURNING
> id"
> "INSERT INTO \"Pet\"(\"owner\",\"nick\",\"type\") VALUES(?,?,?) RETURNING
> id"
> "INSERT INTO \"Pet\"(\"owner\",\"nick\",\"type\") VALUES(?,?,?) RETURNING
> id"
> "SELECT \"Pet\".\"id\",\"Pet\".\"owner\",\"Pet\".\"nick\",\"Pet\".\"type\"
> FROM \"Pet\" INNER JOIN \"Person\" ON
> \"Person\".\"id\"=\"Pet\".\"owner\" WHERE \"Person\".\"name\"=?"
> "SELECT \"Pet\".\"id\",\"Pet\".\"owner\",\"Pet\".\"nick\",\"Pet\".\"type\"
> FROM \"Pet\" INNER JOIN \"Person\" ON
> \"Person\".\"id\"=\"Pet\".\"owner\" WHERE \"Person\".\"name\"=?"
> "BEGIN"
> "DELETE FROM \"Pet\""
> "DELETE FROM \"Person\""
> "COMMIT"
> "DELETE FROM \"Pet\""
> "DELETE FROM \"Person\""
>
> join: [OK]
>
>
>
> The code is sketchier than an etch-a-sketch-sketch. But it is a place
> to start playing from.
>
>
> It can be found at https://github.com/SonOfLilit/persistent, in the
> branch template-haskell-refactoring. It is a fork from
> kaoskorobase/persistent, to enjoy the work he did on separating the TH
> to a separate package.
>
> I'll say again: This is very experimental code, it doesn't work in all
> - or most - cases, but it shows the way, or at least one way. It can
> probably be made to work reasonably well with little work. I'll be
> very happy for any comments or patches cleaning up my code, since this
> is the most advanced Haskell that I've had the opportunity to write
> and many a time I found myself working by guessing or by brute force.
>
> Also, Michael, you might want to port some refactoring that I did to
> the TH code that in my opinion makes it easier to work with, although
> I am sure I over-did it, so apply some thought to it before taking
> everything.
>
> Somehow it happened that this whole thing is one huge commit. I wanted
> it to compile before I commited, and the test needed a lot of new
> features to compile, and it kinda dragged away into days of work
> without commiting... Kids, don't do this at home. I shouldn't have.
>
> I'll be very glad for some code review, I feel it is long due. I'm in
> deeper water than I know how to navigate.
>
>
> -- Aur
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110320/8786d762/attachment-0001.htm>
More information about the web-devel
mailing list