Heroku postgresql operator does not exist












0















I deployed my site to Heroku running postgresql. Before, I had it on the flask development environment running sqlite. The app ran fine when using the schedule view, but when I access the schedule view from Heroku, I get an error.



CLASS



class Task(db.Model):

id = db.Column(db.Integer, primary_key=True)

name = db.Column(db.String(80), index=True)

description = db.Column(db.String(200), index=True)

priority = db.Column(db.Integer)

is_complete = db.Column(db.Boolean) ####might be trouble

url = db.Column(db.String(200), index=True)

est_dur = db.Column(db.Integer)
time_quad = db.Column(db.Integer)

timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

user_id = db.Column(db.Integer, db.ForeignKey('user.id'))


ROUTE



@bp.route('/schedule')
#@login_required
def schedule():


currentUser = current_user.id

q1 = Task.query.filter_by(time_quad=1).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

q2 = Task.query.filter_by(time_quad=2).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

q3 = Task.query.filter_by(time_quad=3).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

q4 = Task.query.filter_by(time_quad=4).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

taskAll = q1 + q2 + q3 + q4


print("current user" + str(currentUser))


return render_template('schedule.html', taskList = taskAll)


ERROR



Exception on /schedule [GET]
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
psycopg2.ProgrammingError: operator does not exist: boolean = integer
LINE 3: ....time_quad = 1 AND task.user_id = 1 AND task.is_complete = 0


HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
[SQL: 'SELECT task.id AS task_id, task.name AS task_name, task.description AS task_description, task.priority AS task_priority, task.is_complete AS task_is_complete, task.url AS task_url, task.est_dur AS task_est_dur, task.time_quad AS task_time_quad, task.timestamp AS task_timestamp, task.user_id AS task_user_id nFROM task nWHERE task.time_quad = %(time_quad_1)s AND task.user_id = %(user_id_1)s AND task.is_complete = %(is_complete_1)s'] [parameters: {'time_quad_1': 1, 'user_id_1': 1, 'is_complete_1': 0}] (Background on this error at: http://sqlalche.me/e/f405)









share|improve this question





























    0















    I deployed my site to Heroku running postgresql. Before, I had it on the flask development environment running sqlite. The app ran fine when using the schedule view, but when I access the schedule view from Heroku, I get an error.



    CLASS



    class Task(db.Model):

    id = db.Column(db.Integer, primary_key=True)

    name = db.Column(db.String(80), index=True)

    description = db.Column(db.String(200), index=True)

    priority = db.Column(db.Integer)

    is_complete = db.Column(db.Boolean) ####might be trouble

    url = db.Column(db.String(200), index=True)

    est_dur = db.Column(db.Integer)
    time_quad = db.Column(db.Integer)

    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))


    ROUTE



    @bp.route('/schedule')
    #@login_required
    def schedule():


    currentUser = current_user.id

    q1 = Task.query.filter_by(time_quad=1).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

    q2 = Task.query.filter_by(time_quad=2).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

    q3 = Task.query.filter_by(time_quad=3).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

    q4 = Task.query.filter_by(time_quad=4).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

    taskAll = q1 + q2 + q3 + q4


    print("current user" + str(currentUser))


    return render_template('schedule.html', taskList = taskAll)


    ERROR



    Exception on /schedule [GET]
    Traceback (most recent call last):
    File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
    File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
    cursor.execute(statement, parameters)
    psycopg2.ProgrammingError: operator does not exist: boolean = integer
    LINE 3: ....time_quad = 1 AND task.user_id = 1 AND task.is_complete = 0


    HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
    [SQL: 'SELECT task.id AS task_id, task.name AS task_name, task.description AS task_description, task.priority AS task_priority, task.is_complete AS task_is_complete, task.url AS task_url, task.est_dur AS task_est_dur, task.time_quad AS task_time_quad, task.timestamp AS task_timestamp, task.user_id AS task_user_id nFROM task nWHERE task.time_quad = %(time_quad_1)s AND task.user_id = %(user_id_1)s AND task.is_complete = %(is_complete_1)s'] [parameters: {'time_quad_1': 1, 'user_id_1': 1, 'is_complete_1': 0}] (Background on this error at: http://sqlalche.me/e/f405)









    share|improve this question



























      0












      0








      0








      I deployed my site to Heroku running postgresql. Before, I had it on the flask development environment running sqlite. The app ran fine when using the schedule view, but when I access the schedule view from Heroku, I get an error.



      CLASS



      class Task(db.Model):

      id = db.Column(db.Integer, primary_key=True)

      name = db.Column(db.String(80), index=True)

      description = db.Column(db.String(200), index=True)

      priority = db.Column(db.Integer)

      is_complete = db.Column(db.Boolean) ####might be trouble

      url = db.Column(db.String(200), index=True)

      est_dur = db.Column(db.Integer)
      time_quad = db.Column(db.Integer)

      timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

      user_id = db.Column(db.Integer, db.ForeignKey('user.id'))


      ROUTE



      @bp.route('/schedule')
      #@login_required
      def schedule():


      currentUser = current_user.id

      q1 = Task.query.filter_by(time_quad=1).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      q2 = Task.query.filter_by(time_quad=2).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      q3 = Task.query.filter_by(time_quad=3).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      q4 = Task.query.filter_by(time_quad=4).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      taskAll = q1 + q2 + q3 + q4


      print("current user" + str(currentUser))


      return render_template('schedule.html', taskList = taskAll)


      ERROR



      Exception on /schedule [GET]
      Traceback (most recent call last):
      File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
      context)
      File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
      cursor.execute(statement, parameters)
      psycopg2.ProgrammingError: operator does not exist: boolean = integer
      LINE 3: ....time_quad = 1 AND task.user_id = 1 AND task.is_complete = 0


      HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
      [SQL: 'SELECT task.id AS task_id, task.name AS task_name, task.description AS task_description, task.priority AS task_priority, task.is_complete AS task_is_complete, task.url AS task_url, task.est_dur AS task_est_dur, task.time_quad AS task_time_quad, task.timestamp AS task_timestamp, task.user_id AS task_user_id nFROM task nWHERE task.time_quad = %(time_quad_1)s AND task.user_id = %(user_id_1)s AND task.is_complete = %(is_complete_1)s'] [parameters: {'time_quad_1': 1, 'user_id_1': 1, 'is_complete_1': 0}] (Background on this error at: http://sqlalche.me/e/f405)









      share|improve this question
















      I deployed my site to Heroku running postgresql. Before, I had it on the flask development environment running sqlite. The app ran fine when using the schedule view, but when I access the schedule view from Heroku, I get an error.



      CLASS



      class Task(db.Model):

      id = db.Column(db.Integer, primary_key=True)

      name = db.Column(db.String(80), index=True)

      description = db.Column(db.String(200), index=True)

      priority = db.Column(db.Integer)

      is_complete = db.Column(db.Boolean) ####might be trouble

      url = db.Column(db.String(200), index=True)

      est_dur = db.Column(db.Integer)
      time_quad = db.Column(db.Integer)

      timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

      user_id = db.Column(db.Integer, db.ForeignKey('user.id'))


      ROUTE



      @bp.route('/schedule')
      #@login_required
      def schedule():


      currentUser = current_user.id

      q1 = Task.query.filter_by(time_quad=1).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      q2 = Task.query.filter_by(time_quad=2).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      q3 = Task.query.filter_by(time_quad=3).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      q4 = Task.query.filter_by(time_quad=4).filter_by(user_id=currentUser).filter_by(is_complete=0).all()

      taskAll = q1 + q2 + q3 + q4


      print("current user" + str(currentUser))


      return render_template('schedule.html', taskList = taskAll)


      ERROR



      Exception on /schedule [GET]
      Traceback (most recent call last):
      File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
      context)
      File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
      cursor.execute(statement, parameters)
      psycopg2.ProgrammingError: operator does not exist: boolean = integer
      LINE 3: ....time_quad = 1 AND task.user_id = 1 AND task.is_complete = 0


      HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
      [SQL: 'SELECT task.id AS task_id, task.name AS task_name, task.description AS task_description, task.priority AS task_priority, task.is_complete AS task_is_complete, task.url AS task_url, task.est_dur AS task_est_dur, task.time_quad AS task_time_quad, task.timestamp AS task_timestamp, task.user_id AS task_user_id nFROM task nWHERE task.time_quad = %(time_quad_1)s AND task.user_id = %(user_id_1)s AND task.is_complete = %(is_complete_1)s'] [parameters: {'time_quad_1': 1, 'user_id_1': 1, 'is_complete_1': 0}] (Background on this error at: http://sqlalche.me/e/f405)






      python postgresql heroku heroku-postgres






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 14:41









      davidism

      65.4k12175189




      65.4k12175189










      asked Nov 23 '18 at 4:44









      normandantzignormandantzig

      2926




      2926
























          1 Answer
          1






          active

          oldest

          votes


















          0














          PostgreSQL has a real boolean type but SQLite doesn't, SQLite generally uses one and zero for true and false (respectively). When you say this:



          filter_by(is_complete=0)


          the 0 will be interpreted by SQLite as "false" but by PostgreSQL as just the number zero; hence the complaint at Heroku about not being able to compare a boolean and an integer in task.is_complete = 0. If you mean "false", say so:



          filter_by(is_complete=False)


          That should be converted to zero when talking to SQLite and the proper boolean 'f' (or false) when talking to PostgreSQL.



          Once you fix that, I strongly recommend that you install PostgreSQL in your development environment if that's the database you're going to be deploying on. You'll have a much better time of things if you develop, test, and deploy on the same stack.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440754%2fheroku-postgresql-operator-does-not-exist%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            PostgreSQL has a real boolean type but SQLite doesn't, SQLite generally uses one and zero for true and false (respectively). When you say this:



            filter_by(is_complete=0)


            the 0 will be interpreted by SQLite as "false" but by PostgreSQL as just the number zero; hence the complaint at Heroku about not being able to compare a boolean and an integer in task.is_complete = 0. If you mean "false", say so:



            filter_by(is_complete=False)


            That should be converted to zero when talking to SQLite and the proper boolean 'f' (or false) when talking to PostgreSQL.



            Once you fix that, I strongly recommend that you install PostgreSQL in your development environment if that's the database you're going to be deploying on. You'll have a much better time of things if you develop, test, and deploy on the same stack.






            share|improve this answer




























              0














              PostgreSQL has a real boolean type but SQLite doesn't, SQLite generally uses one and zero for true and false (respectively). When you say this:



              filter_by(is_complete=0)


              the 0 will be interpreted by SQLite as "false" but by PostgreSQL as just the number zero; hence the complaint at Heroku about not being able to compare a boolean and an integer in task.is_complete = 0. If you mean "false", say so:



              filter_by(is_complete=False)


              That should be converted to zero when talking to SQLite and the proper boolean 'f' (or false) when talking to PostgreSQL.



              Once you fix that, I strongly recommend that you install PostgreSQL in your development environment if that's the database you're going to be deploying on. You'll have a much better time of things if you develop, test, and deploy on the same stack.






              share|improve this answer


























                0












                0








                0







                PostgreSQL has a real boolean type but SQLite doesn't, SQLite generally uses one and zero for true and false (respectively). When you say this:



                filter_by(is_complete=0)


                the 0 will be interpreted by SQLite as "false" but by PostgreSQL as just the number zero; hence the complaint at Heroku about not being able to compare a boolean and an integer in task.is_complete = 0. If you mean "false", say so:



                filter_by(is_complete=False)


                That should be converted to zero when talking to SQLite and the proper boolean 'f' (or false) when talking to PostgreSQL.



                Once you fix that, I strongly recommend that you install PostgreSQL in your development environment if that's the database you're going to be deploying on. You'll have a much better time of things if you develop, test, and deploy on the same stack.






                share|improve this answer













                PostgreSQL has a real boolean type but SQLite doesn't, SQLite generally uses one and zero for true and false (respectively). When you say this:



                filter_by(is_complete=0)


                the 0 will be interpreted by SQLite as "false" but by PostgreSQL as just the number zero; hence the complaint at Heroku about not being able to compare a boolean and an integer in task.is_complete = 0. If you mean "false", say so:



                filter_by(is_complete=False)


                That should be converted to zero when talking to SQLite and the proper boolean 'f' (or false) when talking to PostgreSQL.



                Once you fix that, I strongly recommend that you install PostgreSQL in your development environment if that's the database you're going to be deploying on. You'll have a much better time of things if you develop, test, and deploy on the same stack.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 23 '18 at 6:55









                mu is too shortmu is too short

                354k58699674




                354k58699674
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440754%2fheroku-postgresql-operator-does-not-exist%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                    Alcedinidae

                    Can an atomic nucleus contain both particles and antiparticles? [duplicate]