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.

pymysql.err.InternalError: (1054, u"Unknown column 'comment' in 'field list'")

See original GitHub issue

Trying to switch to master by using this command. bench switch-to-master Above mentioned command get executed succesfully but getting error on firing this command: bench update --patch

Error: pymysql.err.InternalError: (1054, u"Unknown column 'comment' in 'field list'")

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zeroiszerocommented, Apr 11, 2019

I am getting this when switch to master from develop, using the same database

Full error message

View
[frappe@97358416ad3d frappe-bench]$  bench --site site1.local migrate
Migrating site1.local
Executing execute:frappe.db.sql("""update tabComment set comment = substr(comment, 6, locate(":", comment)-6) where comment_type in ("Assigned", "Assignment Completed")""") in site1.local (_1bd3e0294da20)
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 227, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 38, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 81, in execute_patch
    exec(patchmodule.split("execute:")[1],globals())
  File "<string>", line 1, in <module>
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 210, in sql
    self._cursor.execute(query)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, u"Unknown column 'comment' in 'field list'")

Database table ‘tabComment’:

Image Screenshot 2019-04-11 at 5 30 42 PM obviously `comment` and `comment_doctype` fields is missing (possibly field name changed).

Solution:

  1. go to apps/frappe/frappe/patches.txt (master branch of apps: frappe)

  2. change this 2 lines accordingly:

    • comment to _comments
    • comment_doctype to reference_doctype (traced the code. possibly the same field)

    execute:frappe.db.sql("""update tabComment set _comments = substr(_comments, 6, locate(":", _comments)-6) where comment_type in ("Assigned", "Assignment Completed")""")
    execute:frappe.db.sql("update `tabComment` set comment_type='Comment' where reference_doctype='Blog Post' and ifnull(comment_type, '')=''")
    
  3. bench update --patch works

Conclusion:

Possibly caused by database changes in develop branch not merged into master branch.

Pull requests ?

Cannot confirm this is the fix. Frappe expert needed. 😀 🤙🤙🤙

0reactions
mclijaucocommented, Mar 15, 2019

@prashantkt10 Run bench --site site1.local reinstall after switching to master and before doing the patch

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unknown column in 'field list' error on MySQL Update query
I got this error when using GroupBy via LINQ on a MySQL database. The problem was that the anonymous object property ...
Read more >
How to fix MySQL unknown column in field list error
The MySQL unknown column in field list error happens when you put a column name in your SQL script that can't be found...
Read more >
pymysql.err.InternalError: (1054, u"Unknown column ...
pymysql.err.InternalError: (1054, u"Unknown column 'department' in 'field list'") · ERPNext.
Read more >
MySQL Error: 1054 Unknown column in 'field list' - Tech-Assured
If you see this error, it means you have forgotten something while creating table. Let's see the causes & fixes to it. Possible...
Read more >
1927169 – DBAPIError exception wrapped from (pymysql.err ...
InternalError ) (1054, u"Unknown column 'pool.tls_certificate_id' in 'field list'"). Summary: DBAPIError exception wrapped from (pymysql.err.
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