question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extra `t2` while generating query

See original GitHub issue

Model

class MsgLog(Model):
    master_msg_id = CharField(unique=True, primary_key=True)
    text = CharField()
    slave_origin_uid = CharField()
    slave_origin_display_name = CharField(null=True)
    slave_member_uid = CharField(null=True)
    slave_member_display_name = CharField(null=True)
    msg_type = CharField()
    sent_to = CharField()

    class Meta:
        database = SqliteDatabase('data.db')

Query

chat_id = 1
q = MsgLog.select().where(MsgLog.master_msg_id.startswith("%s." % chat_id)).order_by(MsgLog.id.desc())
print(q)

Expected result

SELECT "t1"."master_msg_id", "t1"."text", "t1"."slave_origin_uid", "t1"."slave_origin_display_name", "t1"."slave_member_uid", "t1"."slave_member_display_name", "t1"."msg_type", "t1"."sent_to" FROM "msglog" AS t1 WHERE ("t1"."master_msg_id" LIKE ?) ORDER BY "t1"."id" DESC ['1.%']

Returned result

SELECT "t1"."master_msg_id", "t1"."text", "t1"."slave_origin_uid", "t1"."slave_origin_display_name", "t1"."slave_member_uid", "t1"."slave_member_display_name", "t1"."msg_type", "t1"."sent_to" FROM "msglog" AS t1 WHERE ("t1"."master_msg_id" LIKE ?) ORDER BY "t2"."id" DESC ['1.%']

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Jun 15, 2016

Reopening as I intend to fix.

1reaction
coleifercommented, Jun 22, 2016

The truth is that I removed your comments because they were not constructive, and I was tired of having to defend aspects of my project because you felt entitled to a technical discussion because you happened to disagree with it. When I pointed to you that the things you disagreed with were documented and obviously intentional (via git log), you suggested I was trying to justify, post-hoc, bad design decisions, and was being an irresponsible maintainer. How is that constructive?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql - Adding extra column to view, which is not present in table
CREATE OR REPLACE VIEW DETAILS AS SELECT * FROM ( SELECT T1.ID, T1.AMOUNT, T1.STATUS, T1.ADDEDBY, T1.ADDEDON FROM Table1 T1 UNION ALL SELECT T2....
Read more >
5 Query Transformations
The database can execute the preceding query by joining departments and locations to generate the rows of the view, and then joining this...
Read more >
Documentation: 15: 14.1. Using EXPLAIN - PostgreSQL
You can use the EXPLAIN command to see what query plan the planner creates ... of caching that's expected to occur during the...
Read more >
Optimising SELECTs and Other Queries - MySQL ... - O'Reilly
If so, create an appropriate index and check the query with EXPLAIN again. ... In this case MySQL will scan t1 and look...
Read more >
MySQL 8.0 Reference Manual :: 8.8.2 EXPLAIN Output Format
The EXPLAIN statement provides information about how MySQL executes statements. EXPLAIN works with SELECT , DELETE , INSERT , REPLACE , and UPDATE ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found