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

Abstraction for sql functions/expresions like REGEXP #534

Closed
c33s opened this issue Feb 5, 2014 · 4 comments
Closed

Abstraction for sql functions/expresions like REGEXP #534

c33s opened this issue Feb 5, 2014 · 4 comments

Comments

@c33s
Copy link

c33s commented Feb 5, 2014

in the sluggable behavior it was already hacked in: propelorm/Propel#721

        $platform = $this->getTable()->getDatabase()->getPlatform();
        if ($platform instanceof PgsqlPlatform) {
            $script .= "->where('q." . $this->getColumnForParameter('slug_column')->getPhpName() . " ' . (\$alreadyExists ? '~*' : '=') . ' ?', \$alreadyExists ? '^' . \$slug2 . '[0-9]+$' : \$slug2)";
        } elseif ($platform instanceof MssqlPlatform) {
            $script .= "->where('q." . $this->getColumnForParameter('slug_column')->getPhpName() . " ' . (\$alreadyExists ? 'like' : '=') . ' ?', \$alreadyExists ? '^' . \$slug2 . '[0-9]+$' : \$slug2)";
        } elseif ($platform instanceof OraclePlatform) {
            $script .= "->where((\$alreadyExists ? 'REGEXP_LIKE(' : '') . 'q." . $this->getColumnForParameter('slug_column')->getPhpName() . " ' . (\$alreadyExists ? ',' : '=') . ' ?' . (\$alreadyExists ? ')' : ''), \$alreadyExists ? '^' . \$slug2 . '[0-9]+$' : \$slug2)";
        } else {
            $script .= "->where('q." . $this->getColumnForParameter('slug_column')->getPhpName() . " ' . (\$alreadyExists ? 'REGEXP' : '=') . ' ?', \$alreadyExists ? '^' . \$slug2 . '[0-9]+$' : \$slug2)";
        }

there are also some discussions if it is necessary to use REGEXP or to rollback to the old behavior which is not using this function.
nevertheless would it be a great improvement to have an abstraction to such functions and expressions.

@marcj
Copy link
Member

marcj commented Apr 16, 2014

Oh, this has been fixed with dd599ce

@marcj marcj closed this as completed Apr 16, 2014
@c33s
Copy link
Author

c33s commented Apr 16, 2014

this is not really a fix for this issue.
it is all about abstraction. i think its no solution to solve a special function regex with another special function length
as discussed in the other ticket, length is not compatible with mssql. so again i stand for an abstaction for many special functions used in propel.

same for the other ticket i created: #261

i think it would be good to have more abstractions of such functions

@marcj
Copy link
Member

marcj commented Apr 16, 2014

We have already abstracted regex and lengths as you see in my commit. See adapter classes for more information. Propel is a ORM, not a plain DBAL.

@c33s
Copy link
Author

c33s commented Apr 16, 2014

oh, my fault.
nice one.

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