lucianmachado / sails-oracle-database

Oracle Database adapter for Sails.js
MIT License
2 stars 7 forks source link

Model.count() is not working #3

Closed cope closed 7 years ago

cope commented 7 years ago

Hey @lucianmachado,

As I mentioned in issue #2 we recently switched from sails-oracle-db to sails-oracle-database, and that now casues the Model.count() method to fail :(

This in turn ruins our paging functionality, of course...

Executing query:
SELECT COUNT(*) as count FROM (
    SELECT * FROM "MY_TABLE" WHERE (
        (upper("MY_TABLE"."NAME")LIKE $1) OR 
        (upper("MY_TABLE"."DESCRIPTION")LIKE $2) OR 
        (upper("MY_TABLE"."TYPE")LIKE $3) OR 
        (upper("MY_TABLE"."CREATED_BY")LIKE $4) OR 
        (upper("MY_TABLE"."CODE_NAME")LIKE $5) OR 
        (upper("MY_TABLE"."PRODUCT_FAMILY")LIKE $6) OR 
        (upper("MY_TABLE"."PROJECT_STATUS")LIKE $7) OR 
        (upper("MY_TABLE"."PRODUCT_ID")LIKE $8) OR 
        (upper("MY_TABLE"."PRODUCT_TYPE")LIKE $9) OR 
        (upper("MY_TABLE"."OWNER")LIKE $10)
    )
) AS "MY_TABLE"
count
Error (E_UNKNOWN) :: Encountered an unexpected error
: ORA-01036: illegal variable name/number

Details:  Error: ORA-01036: illegal variable name/number

Do you maybe have an idea why the count fails? :(

lucianmachado commented 7 years ago

Hello @cope,

I just published a fix to this issue, can you update your package to the latest version?

Regards!

cope commented 7 years ago

I use 0.3.0 Is that the latest?

cope commented 7 years ago

I uninstalled and reinstalled, and the error is now different: Details: Error: ORA-00933: SQL command not properly ended

cope commented 7 years ago

I found this on stackoverflow.

I will trz to figure out in the oracle-adapter code why it works...

cope commented 7 years ago
Executing query: SELECT COUNT(*) as count FROM (SELECT * FROM "MY_TABLE" ) AS "MY_TABLE"
Error (E_UNKNOWN) :: Encountered an unexpected error
: ORA-00933: SQL command not properly ended

I think I found the place where to fix it, looking further.

cope commented 7 years ago

Ah... I think you need to make a new npm release...

After uninstalling and reinstalling, my adapter.js still has the count method, even though here in the repository, the adapter.js file does not have it anymore.

Once I removed the count method from the adapter.js file, the count worked :)

So, I am 99% sure that all we need is a 0.3.2 release for npm :)

lucianmachado commented 7 years ago

@cope, can you try to update again?

The latest version is 0.3.2, the package in the npmjs was outdated... my bad 😄

cope commented 7 years ago

Running npm update :) One sec...

cope commented 7 years ago

It works!!! :)