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

validates_uniqueness_of should respect aliases #35

Closed
koterpillar opened this issue Apr 15, 2010 · 2 comments
Closed

validates_uniqueness_of should respect aliases #35

koterpillar opened this issue Apr 15, 2010 · 2 comments

Comments

@koterpillar
Copy link

As the other validators already do, it would be good to enable to validate uniqueness of aliased attributes:

class User extends ActiveRecord\Model {
    static $alias_attribute = array( 'login' => 'meh_this_is_a_legacy_table' );
    static $validates_uniqueness_of = array( 'login' );
}

Currently, the code fails with

Uncaught exception 'ActiveRecord\\DatabaseException' with message '42S22, 1054, Unknown column 'login' in 'where clause''

Using the original name for the attribute is a workaround, but will not look nice with validators:

Meh this is a legacy table is not unique
@koterpillar
Copy link
Author

I have (hopefully) fixed it in 7ca77757abd4d36447c1ceb028e8b373eec851cf.

@kla
Copy link
Collaborator

kla commented Apr 28, 2010

This has been fixed in the integration branch. Should be in the master branch shortly.

http://github.com/kla/php-activerecord/commit/c658e7e41df94c000aee836a743c973e2238327a

This issue was closed.
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

2 participants