Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Duplicate column name 'id' when the scope already selects columns #2

Open
mbillard opened this issue Apr 2, 2014 · 1 comment
Open

Comments

@mbillard
Copy link

mbillard commented Apr 2, 2014

If the scope already selects columns:

@items = Item.select('`items`.*')

Then calling the cache on the scope directly will raise an error:

cache [@items] do
  ...

The error:

Mysql2::Error: Duplicate column name 'id': SELECT CONCAT(`id`, '-', `updated_at`) FROM (SELECT  `items`.*, items.id, items.updated_at FROM ...
@mbillard
Copy link
Author

mbillard commented Apr 2, 2014

A workaround is to explicitly load the relation before calling the cache:

@items.load
cache [@items] do
  ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant