Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible ambiguous column issue for only_deleted #26

Closed
defconomicron opened this issue Jun 27, 2012 · 2 comments
Closed

Possible ambiguous column issue for only_deleted #26

defconomicron opened this issue Jun 27, 2012 · 2 comments

Comments

@defconomicron
Copy link

Hello.

Suppose there were 2 database tables named alpha and beta and both had a deleted_at column...

One would get an ambiguous column "deleted_at" if the following were attempted:

Alpha.joins(:beta).only_deleted

Perhaps this:

def only_deleted
  unscoped {
    where("deleted_at is not null")
  }
end

Should be this:

def only_deleted
  unscoped {
    where("#{self.table_name}.deleted_at is not null")
  }
end

Or perhaps I am attempting to use this method in a manner that is not intended.

@radar
Copy link
Collaborator

radar commented Jun 27, 2012

No, you're right. It should indeed be scoping by the table name. Can you submit a patch for this please?

@radar radar closed this as completed Nov 15, 2012
@thromera
Copy link
Contributor

I'm sorry to reopen this issue, but is the problem fixed ? We have from times to times this issue in our project, "ambiguous column active" when using only_deleted.

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

No branches or pull requests

3 participants