选择列表中不明确的列命名 -- DataMapper for Ruby
在 DataMapper 中,我有这样的表:
Foo
===
id Integer
other_columns Whatever
Fuzz
===
id Integer
other_columns Whatever
对于关联:
class Fuzz
has 1, :foo, :child_key => :id
end
当我调用时: Fuzz.first.foo
DataMapper 生成如下 SQL: select raw_sql_.* from(SELECT "ID", "OTHER_COLUMNS", "ID" FROM "FOO" WHERE ... ORDER BY "ID")
由于存在“ORDER BY”子句,Oracle 返回说: 选择列表中的列命名不明确
如何避免这种情况?这是一个遗留数据库系统,因此我无法更改架构。
In DataMapper, I have tables like this:
Foo
===
id Integer
other_columns Whatever
Fuzz
===
id Integer
other_columns Whatever
For associations:
class Fuzz
has 1, :foo, :child_key => :id
end
When I call:
Fuzz.first.foo
DataMapper generates SQL like this:
select raw_sql_.* from(SELECT "ID", "OTHER_COLUMNS", "ID" FROM "FOO" WHERE ... ORDER BY "ID")
Because of the "ORDER BY" clause, Oracle comes back saying:
ambiguous column naming in select list
How do I avoid this situation? This is a legacy database system, so I have no option to change the schema.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的帖子中,不清楚为什么您将 ID 添加到内部选择两次。是不是因为你从两个表中选择了ID?然后,在选择列表中,在它们前面加上表名称,并为它们提供您选择的别名,例如
From your post, it is not clear why you add ID twice to the inner select. Is it because you select IDs from two tables? Then, in the select list, precede them with table names and give aliases of your choice to them like