DDC-776: Persisters use a fixed "SELECT" SQL statements #959

Open
opened 2026-01-22 12:57:20 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Aug 29, 2010).

Jira issue originally created by user aarondm:

I am currently trying to work with BINARY columns with Doctrine 2 and MSSQL. In order to get my Entities working I had to create a custom Mapping Type for Binary columns. All went well in this case and I've got it running.

The problem arises when I am attempting to use Associative mapping (OneToOne/ManyToMany). The problem is, in order to do a select for an SQL column, I had to create a DQL function called "CONVERT" so that I use WHERE statements:

        return $this->createQueryBuilder('u')
            ->where("u.id = CONVERT('binary', :id, 1)")
            ->setParameter('id', $id)
            ->getQuery()
            ->getSingleResult();

As you see, I must do this in order to get a result.

However, when I'm using associative mapping; this is what it does:

    return 'SELECT ' . $this->_getSelectColumnListSQL() 
         . ' FROM ' . $this->*class->getQuotedTableName($this->*platform) . ' '
         . $this->*getSQLTableAlias($this->*class->name)
         . $joinSql
         . ($conditionSql ? ' WHERE ' . $conditionSql : '')
         . $orderBySql 
         . $lockSql;

As you can see, its some what hard coded and I cannot change it without changing the actual code in
Doctrine\ORM\Persisters\BasicEntityPersister.php

So, I would first like to know if there was maybe a way you could allow us to customize the SELECT statement that the persisters use - or maybe (though I'm not sure how this will be done) make them use user-defined repository functions?

Like $myRepo->find($identifier)

Not entirely sure if I explained this properly and I do realize my circumstance is highly odd - but this does seem like a limitation and because of this I cannot use associative mapping.

Originally created by @doctrinebot on GitHub (Aug 29, 2010). Jira issue originally created by user aarondm: I am currently trying to work with BINARY columns with Doctrine 2 and MSSQL. In order to get my Entities working I had to create a custom Mapping Type for Binary columns. All went well in this case and I've got it running. The problem arises when I am attempting to use Associative mapping (OneToOne/ManyToMany). The problem is, in order to do a select for an SQL column, I had to create a DQL function called "CONVERT" so that I use WHERE statements: ``` return $this->createQueryBuilder('u') ->where("u.id = CONVERT('binary', :id, 1)") ->setParameter('id', $id) ->getQuery() ->getSingleResult(); ``` As you see, I must do this in order to get a result. However, when I'm using associative mapping; this is what it does: ``` return 'SELECT ' . $this->_getSelectColumnListSQL() . ' FROM ' . $this->*class->getQuotedTableName($this->*platform) . ' ' . $this->*getSQLTableAlias($this->*class->name) . $joinSql . ($conditionSql ? ' WHERE ' . $conditionSql : '') . $orderBySql . $lockSql; ``` As you can see, its some what hard coded and I cannot change it without changing the actual code in Doctrine\ORM\Persisters\BasicEntityPersister.php So, I would first like to know if there was maybe a way you could allow us to customize the SELECT statement that the persisters use - or maybe (though I'm not sure how this will be done) make them use user-defined repository functions? Like $myRepo->find($identifier) Not entirely sure if I explained this properly and I do realize my circumstance is highly odd - but this does seem like a limitation and because of this I cannot use associative mapping.
admin added the Improvement label 2026-01-22 12:57:20 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 23, 2013):

Comment created by locs:

Hi, i try to make my custom type for binary field in MSSQL.
I don't find own, can you please show me your custom type binary?
Thks a lot.

@doctrinebot commented on GitHub (Apr 23, 2013): Comment created by locs: Hi, i try to make my custom type for binary field in MSSQL. I don't find own, can you please show me your custom type binary? Thks a lot.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#959