Displaying 20 results from an estimated 35 matches for "t0_r0".
2006 May 16
1
:conditions on has_one realationship
...I should be able to do a
@people = Person.find :all, :include => :active_membership
in my controller and it should find any records from the table people
that have an active membership in table memberships. As far as I can
tell this should generate this SQL:-
SELECT people.`id` AS t0_r0, people.`firstname` AS t0_r1,
people.`surname` AS t0_r2, memberships.`id` AS t1_r0,
memberships.`person_id` AS t1_r1, memberships.`startdate` AS t1_r3,
memberships.`enddate` AS t1_r4 FROM people LEFT OUTER JOIN
memberships ON memberships.person_id = people.id WHERE memberships.id
is not n...
2008 Mar 28
6
Eager Loading + Confusion
...umn name ''funding_entity''.
Okay, its checking the database and not the model.
Well, funding_entities is a table... maybe that will work?
funding_entities.name => Incorrect syntax near ''\.''.: SELECT * FROM
(SELECT TOP 5 * FROM (SELECT TOP 5 [grants].[id] AS t0_r0, [grants].
[created_by] AS t0_r1, ... (40 more of these) ... ORDER BY
funding_entities.name asc) AS tmp1 ORDER BY funding_entities\.\[name\]
DESC) AS tmp2 ORDER BY funding_entities\.\[name\] asc
Not sure why this happens. Its trying to do funding_entities.[name]
or something with escape character...
2005 Apr 27
5
Eager load mysteriously deletes records
...[4;35mTodo Columns (0.010000) [0;37mSHOW FIELDS FROM todos
[4;33mWhens Columns (0.000000) [1;37mSHOW FIELDS FROM whens
[4;35mTodo Load Including Associations (0.000000) [0;37mSELECT
todos.position AS t0_r6, todos.due AS t0_r7, whens.todo_id AS t1_r0,
whens.id AS t1_r1, todos.repeat_id AS t0_r0, whens.category_id AS t1_r2,
todos.hour AS t0_r1, todos.priority AS t0_r2, todos.id AS t0_r3,
todos.description AS t0_r4, todos.kind_id AS t0_r5 FROM todos LEFT OUTER
JOIN whens ON whens.todo_id = todos.id ORDER BY position ASC
[4;33mCategory Load (0.000000) [1;37mSELECT * FROM categories
WHER...
2008 Jun 13
2
Rails 2.1.0 - find with :include and missing JOIN in SQL query
...e problems is caused by :include in AR.find. Rails 1.2.6
generates totally different SQL query than
2.1.0. Here''s Rails find query and generated SQL queries:
Foo.find(:all, :include => :ticket, :conditions => (''project_id =>
1''))
Rails 1.2.6
SELECT foos.`id` AS t0_r0 ... FROM foos LEFT OUTER JOIN tickets ON
tickets.id = foos.ticket_id WHERE (project_id = 1) # works fine
Rails 2.1.0
SELECT * FROM `foos` WHERE (project_id = 1) # JOIN is missing and
Rails complains about missing project_id column in foos table
Foos table doesn''t have project_id column,...
2006 Jun 25
2
how to write the codes in view?(newbie question)
...I have two tables and want to join them.
<genres>
id
genre_name
genre_order
<links>
id
genre_id
name
symbol
url
order
display
etc
The code of links_Controller is like below.
def list
@links = Genre.find(:all,:include => :link)
end
Below is the mysql log.
SELECT genres.`id` AS t0_r0, genres.`genre_n
ame` AS t0_r1, genres.`genre_order` AS t0_r2, links.`id` AS t1_r0,
links.`genre_
id` AS t1_r1, links.`name` AS t1_r2, links.`symbol` AS t1_r3,
links.`url` AS t1_
r4, links.`order` AS t1_r5, links.`display` AS t1_r6, links.`etc` AS
t1_r7 FROM
genres LEFT OUTER JOIN links ON links.g...
2008 Feb 09
0
MVC interplay to query multiple models
...", "id"=>"1", "controller"=>"calls"}
Call Load (0.001115) SELECT * FROM calls WHERE (calls."id" = 1)
Rendering within layouts/calls
Rendering calls/show
Call Load Including Associations (0.002511) SELECT calls."id" AS
t0_r0, calls."login_id" AS t0_r1, calls."created_at" AS t0_r2,
calls."comment" AS t0_r3, logins."id" AS t1_r0, logins."login" AS t1_r1,
logins."employee_id" AS t1_r2 FROM calls LEFT OUTER JOIN logins ON
logins.id = calls.login_id
Completed i...
2007 Dec 12
2
possible bug in eager loading
...ername AS alias_0 FROM users
LEFT OUTER JOIN user_data ON user_data.user_id = users.id LEFT OUTER
JOIN user_data_fields ON user_data_fields.id = user_data.field_id ) AS
id_list ORDER BY id_list.alias_0 DESC LIMIT 50
User Load Including Associations (0.026093) SELECT users."id" AS
t0_r0, users."username" AS t0_r1, users."password" AS t0_r2, <lots of
more fields>, user_data."id" AS t1_r0, user_data."entered_when" AS
t1_r1, <lots of more fields> FROM users LEFT OUTER JOIN user_data ON
user_data.user_id = users.id LEFT OUTER JOIN...
2006 Jan 22
2
suggest for "ambiguous column" when JOIN associated tables
...cases when you try to use :include parameter for the .find
method,
ActiveRecord generates incorrect query which brings to SQL error
"ambiguous column name".
So, for the fist case (self-refferal join), ActiveRecord will generate
this query:
SELECT keywords.id AS t1_r0, keywords.id AS t0_r0, keywords.group_id AS
t1_r2, keywords.group_id AS t0_r2, FROM keywords LEFT OUTER JOIN
keywords ON keywords.id = keywords.group_id;
My point is to use AS statement to refer JOIN''ed tables as aliases, so
we can produce query like:
SELECT keywords_t1.id AS t1_r0, keywords.id AS t0_r0,...
2006 Jan 09
3
Include with two references of one model of the same table
...d" AS t2_r3, matches."venue_id" AS t1_r9, matches."hometeam_id" AS t2_r4, matches."matchtime_start" AS t2_r5, matches."id" AS t1_r0, matches."matchtime_stop" AS t2_r6, matches."awayteam_goals" AS t1_r1, teams_seasons."id" AS t0_r0, matches."season_id" AS t2_r7, matches."hometeam_goals" AS t1_r2, teams_seasons."team_id" AS t0_r1, matches."league_id" AS t2_r8, matches."awayteam_id" AS t1_r3, teams_seasons."season_id" AS t0_r2, matches."venue_id" AS t2_r9, ma...
2009 Feb 22
2
Mysql error unknown column 'columns.user_id'
Had this error when trying to add comments to another user''s photo.
ActiveRecord::StatementInvalid in User photosController#show
Mysql::Error: Unknown column ''comments.user_id'' in ''on clause'': SELECT
photos.`id` AS t0_r0, photos.`user_id` AS t0_r1, photos.`title` AS
t0_r2, photos.`body` AS t0_r3, photos.`created_at` AS t0....
I did create a user_id column in the comments as such:
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.column :photo_id, :integer...
2007 May 22
2
find :all :include broken on Oracle 10
Hi,
I am trying the following in Ruby using InstantRails 1.7 on WindowsXP
Publication.find(:all, :include => [:doc_type, :release_state] )
but I get the error:
OCIError: ORA-00904: "DOC_TYPES"."PUBLICATION_ID": invalid identifier:
SELECT publications.id AS t0_r0, publications.docid AS t0_r1,
publications.doc_type_id AS t0_r2, publications.title AS t0_r3,
publications.lang AS t0_r4, publications.keywords AS t0_r5,
publications.cvsdir AS t0_r6, publications.publishername AS t0_r7,
publications.publisherorg AS t0_r8, publications.release_state_id AS
t0_r9, do...
2009 Jan 04
3
Table associated problem using belongs_to
...s_to :user,
:class_name => "User",
:foreign_key => "user_name"
end
Then I run Package.find(1, :include => :user) in Rails console. From the
log, I can see the sql is:
Package Load Including Associations (0.000309) SELECT
`packages`.`id` AS t0_r0, `packages`.`name` AS t0_r1,
`packages`.`user_name` AS t0_r2, `users`.`id` AS t1_r0, `users`.`name`
AS t1_r1, `users`.`full_name` AS t1_r2 FROM `packages` LEFT OUTER JOIN
`users` ON `users`.id = `packages`.user_name WHERE (`packages`.`id` = 1)
But I cannot find the parameters for belongs_to to set...
2006 May 20
3
In a find, can''t you use both :include and :limit ?
....id
AND
es.skill_id = 3
In Rails, I figured out that the right way to do that *may* be:
employees = Employee.find(
:all,
:include => :skills,
:conditions => ["skill_id = ?",3]
)
-- and it works. The SQL in development.log looks correct (if verbose):
SELECT employees.`id` AS t0_r0, employees.`title` AS t0_r1,
employees.`desc_short` AS t0_r2, employees.`picture_url` AS t0_r3,
employees.`contract` AS t0_r4, employees.`available` AS t0_r5,
employees.`address` AS t0_r6, employees.`comments` AS t0_r7,
employees.`creation_date` AS t0_r9, employees.`last_update` AS t0_r10,
emp...
2006 May 23
5
AR Caching and Reflection
When I do this:
term = Term.find(1, :include => :definition)
term.definition.term
Two SQL queries are fired, why?
--
Posted via http://www.ruby-forum.com/.
2012 Aug 31
3
Feature Request: Auto-infer .includes from .where with ActiveRecord queries
In the following snippet, can''t the includes being inferred from the where
clause?
Order.includes(:items).where(:items => { :category => [1,2,3] })
Can''t the includes be inferred from the where clause?
Order.where(:items => { :category => [1,2,3] })
Would this conflict with any existing usages of the where clause and
hashes?
--
You received this
2006 Jul 02
18
JOIN conditions
Hi,
how can I get Rails to generate SQL queries with conditions in the JOIN clause?
What I would want is:
SELECT * FROM people p
LEFT OUTER JOIN jobs j (p.job_id = j.id AND j.salary > 9999999)
I tried
People.find(:all, :include => ''jobs'', :conditions => ''jobs.salary > 9999999'')
but that generates
SELECT * FROM people p
LEFT OUTER
2006 Jul 17
1
acts_as_tree and :include
...:gb_entries, :per_page => 15, :order => ''created_at DESC'', :include => :children
when i run that, i get the followin error:
ActiveRecord::StatementInvalid (Mysql::Error: #23000Column
''created_at'' in order clause is ambiguous: SELECT gb_entries.`id` AS
t0_r0, gb_entries.`name` AS t0_r1, gb_entries.`email` AS t0_r2,
gb_entries.`homepage` AS t0_r3, gb_entries.`message` AS t0_r4,
gb_entries.`created_at` AS t0_r5, gb_entries.`parent_id` AS t0_r6,
childrens_gb_entries.`id` AS t1_r0, childrens_gb_entries.`name` AS
t1_r1, childrens_gb_entries.`email` AS t1_r2...
2006 Apr 11
2
how to order by a related class???
...e the authors table with something like
@book_pages, @books =
paginate :book,
:order => ''title'', :per_page => 10,
:include => [:author]
then rails generates the following
SELECT * FROM (
SELECT TOP 10 * FROM (
SELECT TOP 10
books.[id] AS t0_r0,
books.[title] as t0_r1,
authors.[id] as t1_r0,
authors.[name] as t1_r1
FROM
books LEFT OUTER JOIN authors ON books.author_id = authors.id
ORDER BY name )
AS tmp1 ORDER BY name desc)
AS tmp2 ORDER BY name
The inner "ORDER BY NAME" can be acomplished, provided there ar...
2006 Apr 19
2
I need help in ActiveRecord..
I have this Product.find(:all, :include => [:brand, :category, :type],
:group =>
"description"), but it dont group by description why?
Bruno
--
Posted via http://www.ruby-forum.com/.
2006 Mar 14
3
cascading eager loading patch not working in oracle
Notice the "AS" keyword appears many times. Oracle does not support this
keyword:
ActiveRecord::StatementInvalid: OCIError: ORA-00905: missing keyword:
SELECT tim
esheets.id AS t0_r0, timesheets.start_date AS t0_r1, timesheets.status
AS t0_r2,
timesheets.cost AS t0_r3, timesheets.charge AS t0_r4,
timesheets.employee AS t0
_r5, employees.id AS t1_r0, employees.name AS t1_r1,
employees.start_date AS t1_
r2, employees.cost AS t1_r3, employees.charge AS t1_r4,
employees.userna...