Git Product home page Git Product logo

Comments (10)

czsergey avatar czsergey commented on July 18, 2024

Have the same issue.
The problem occurs only if you use and/or condition. If there is only one codition, it does not fail.
I tried to add tablePrefix into createSqlSelectCountStar but then it fail on single condition query.

from greendao.

czsergey avatar czsergey commented on July 18, 2024

Here is the patch:

diff --git a/DaoCore/src/de/greenrobot/dao/internal/SqlUtils.java b/DaoCore/src/de/greenrobot/dao/internal/SqlUtils.java
index 365f949..42d2f2c 100644
--- a/DaoCore/src/de/greenrobot/dao/internal/SqlUtils.java
+++ b/DaoCore/src/de/greenrobot/dao/internal/SqlUtils.java
@@ -106,9 +106,9 @@ public class SqlUtils {
     }

     /** Creates SELECT COUNT(*) with a trailing space. */
-    public static String createSqlSelectCountStar(String tablename) {
+    public static String createSqlSelectCountStar(String tablename, String tableAlias) {
         StringBuilder builder = new StringBuilder("SELECT COUNT(*) FROM ");
-        return builder.append(tablename).append(' ').toString();
+        return builder.append(tablename).append(' ').append(tableAlias).append(' ').toString();
     }

     public static String createSqlDelete(String tablename, String[] columns) {
diff --git a/DaoCore/src/de/greenrobot/dao/query/QueryBuilder.java b/DaoCore/src/de/greenrobot/dao/query/QueryBuilder.java
index 2fcea5e..2a4ca2e 100644
--- a/DaoCore/src/de/greenrobot/dao/query/QueryBuilder.java
+++ b/DaoCore/src/de/greenrobot/dao/query/QueryBuilder.java
@@ -326,9 +326,9 @@ public class QueryBuilder<T> {
      */
     public CountQuery<T> buildCount() {
         String tablename = dao.getTablename();
-        String baseSql = SqlUtils.createSqlSelectCountStar(tablename);
+        String baseSql = SqlUtils.createSqlSelectCountStar(tablename, tablePrefix);
         StringBuilder builder = new StringBuilder(baseSql);
-        appendWhereClause(builder, tablename);
+        appendWhereClause(builder, tablePrefix);
         String sql = builder.toString();

         if (LOG_SQL) {

from greendao.

hf avatar hf commented on July 18, 2024

This also happens to me.

from greendao.

bluesliverx avatar bluesliverx commented on July 18, 2024

+1, please merge this in and re-release

from greendao.

renaudcerrato avatar renaudcerrato commented on July 18, 2024

Seems an unsupported project... Moving to ormlite..

from greendao.

bluesliverx avatar bluesliverx commented on July 18, 2024

@greenrobot, are you still around?

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

Of course. Like we blogged a month ago, we're currently busy with project work, but are preparing to accept community contribution: http://greendao-orm.com/2013/07/09/community-contributions/

from greendao.

bluesliverx avatar bluesliverx commented on July 18, 2024

I'm not sure @czsergey wants to sign that for a simple patch. If you really would like that done, though, I can do it and submit the "official" pull request.

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

Don't worry about signing, I'll fix it during the next days.

from greendao.

greenrobot avatar greenrobot commented on July 18, 2024

fixed in 97c75b9. Watch for 1.3.2 release...

from greendao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.