#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11 12 13
Top Prev 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 Next
#rubyonrails
<victori> ya I did its not pulling the right distinct
<victori> it worked correctly back in 1.1.6
<victori> SELECT * FROM (SELECT DISTINCT ON (users.id) users.id, blogs.created_at AS alias_0 FROM users LEFT OUTER JOIN blogs ON blogs.user_id = users.id WHERE (display = true and blogs.user_id is not null and blogs.user_id != 2) ) AS id_list ORDER BY id_list.alias_0 DESC LIMIT 10; --- distinct on users.id needs to be users.name to pull correctly
<pstickne> is there a reason it's :user.id?
<victori> err I did not mean to add that :distinct bit
<victori> hell its not even valid
<victori> but the point is, sql is generated incorrectly
<pstickne> you tell it to :user.id (which isn't valid normal ruby; where is users.name coming from?)
<victori> its me modifying the sql query
<victori> I did not have that :distinct bit in
<pstickne> User.find(:all,:include=>:blogs, :distinct=>:user.id, .... #???
<victori> ArgumentError: Unknown key(s): distinct
<tpope> where is :distinct in the api?
<victori> its not
<tpope> that was my point :)
<tpope> :select => 'distinct *'
<quik_> is instiki finally in some form of a complete state?
<MartinCleaver> anyone here use instantrails with eclipse?
<MartinCleaver> I'm thinking about connecting sql explorer to the instant rails mysql, but want to check that's a good idea
<hydo> Am I doing something dumb, or does :conditions barf for no real reason if given three args? ie. :conditions => [ "name = ? and date = ?", name, date ] works fine. but "name = ? and date = ? and time = ?" throws an sql exception.
<hydo> or maybe this is more dependant on the driver used.
<hydo> time works by the way if you drop one of the other two.
<pstickne> time isn't reserved or anything silly? and you are passing 3 arguments, right? and the right types
<pstickne> ?
<hydo> yea, I tested it in the console just to make sure before I came here :)
<pstickne> yes to all questions? and what error?
<tpope> pastie the backtrace
<hydo> yes to all questions.
<hydo> ok... one sec.
<hydo> pastie: hi
<victori> must kill AR ;-(
<pstickne> must. follow. api.
<victori> I am
<victori> and the fact that its giving me a bogus result
<pstickne> how is it bogus now after tpope brought up the previous error?
<victori> User.find(:all,:include=>:blogs,:limit=>10,:order=>'blogs.created_at desc',:conditions=>'display = true').first.name -- shortened -- now if you look at this it retrieves the users with the latest blog posts, or it should
<victori> however it does not do it
<victori> I added the first.name since I am debugging
<|PiP|> pstickne: it worked using referrer_username= in that it makes the association if the username is correct, but it doesn't give an error when the username does not exist.
<tpope> you can't sort on a column in an association like that
<tpope> it's going to come back a jumbled mess
<pastie> http://pastie.caboo.se/41322 by hydo.
<victori> so how would I write it to retrieve the users distinctly with their latest blog posts then?
<pstickne> |PiP|, just assign, if possible, in that setter (it should really assign to referrer or some such internally), and then validate that referrer is set
<tpope> it's going to be db dependent
<victori> so I can only make it db dependent?
<victori> ok then
<|PiP|> pstickne: but how can i verify that the referrer is valid?
<pstickne> |PiP|, so if the m.referrer_name = "Bogus" doesn't set, it returns nil (which is likely just discarded) and doesn't set m.referrer
<tpope> well, there's no portable sql I can think of to do it
Previous Page Next Page