rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

String to Integer Conversion issue on PgSQL #50

Closed rtablada closed 9 years ago

rtablada commented 9 years ago

I'm not sure if anyone else has run into this issue but I have been getting a lot of errors when trying to use withAnyTag and withAllTag scopes in pg databases.

After some research it seems that it was a conversion issue since it was trying to do a join from an Integer id column from my models to the taggable_id field in the tagging_tagged table.

I was able to hack around this by channing the taggable_id field to an integer.

Not sure if there's something we could do to make sure things are cast to the proper type from the query scopes in this package or maybe ship two different migration for string vs integer primary keys?


Note: Looking around this error may not be replaceable on MySQL databases since MySQL will do automatic field casts while PG and others require explicit type cast declarations.

rtconner commented 9 years ago

The only thing I know to do is a global "all primary keys are strings" or "all primary keys are integers" type config. So I guess that will have to do.

rtconner commented 9 years ago

Added a config option of 'primary_keys_type' in version 1.1.0 (defaults to integer now)