subsonic / SubSonic-2.0

SubSonic 2.0 Home
http://subsonic.github.io/
Other
80 stars 45 forks source link

GetCountSelect() returns invalid SQL (SubSonic 2.2, Oracle 9.2) #21

Closed FrostyZoob closed 12 years ago

FrostyZoob commented 13 years ago

I'm using SubSonic 2.2 with Oracle 9.2 and .NET 2.0.

Calling SqlQuery.GetRecordCount() generates an Oracle error:

ORA-00923: FROM keyword not found where expected

The method call generates SQL which looks like the following:

SELECT count(*) as 'yadda' from SOMESCHEMA.SOMETABLE

The culprit appears to be Aggregate.ToString(). Specifically, the format string it uses contains single quotes which are not allowed (in column aliases, at any rate) in Oracle. A workaround that I've implemented was to override GetCountSelect in the OracleGenerator class which simply replaces all single quotes with double quotes:

    public override string GetCountSelect()
    {
        return base.GetCountSelect().Replace('\'', '"');
    }