Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual Fields: Error "Unknown column" #24660

Closed
zongo811 opened this issue Feb 1, 2024 · 2 comments · Fixed by #24666
Closed

Virtual Fields: Error "Unknown column" #24660

zongo811 opened this issue Feb 1, 2024 · 2 comments · Fixed by #24666

Comments

@zongo811
Copy link

zongo811 commented Feb 1, 2024

Description of the issue

I want to show the value of a certain field in two Tab breaks, so I defined a virtual field that mirrors the value of an existing field, see below. This works in Form View, but when I enter List View, an "Unknown column" error occurs.

List View tries to fetch the virtual field from the database.
If I use @Property in the python controller the error doesn't occur.

Context information (for bug reports)

image

Output of bench version

erpnext 14.61.1
frappe 14.63.0

Steps to reproduce the issue

  1. In a DT create a virtual field, in options use "doc.some_other_field" to mirror the value
  2. Switch to List View.

Observed result

Error "Unknown column" occurs

Expected result

Error "Unknown column" does not occur

Stacktrace / full error message

09:06:27 web.1            | Traceback (most recent call last):
09:06:27 web.1            |   File "apps/frappe/frappe/app.py", line 95, in application
09:06:27 web.1            |     response = frappe.api.handle()
09:06:27 web.1            |   File "apps/frappe/frappe/api.py", line 55, in handle
09:06:27 web.1            |     return frappe.handler.handle()
09:06:27 web.1            |   File "apps/frappe/frappe/handler.py", line 47, in handle
09:06:27 web.1            |     data = execute_cmd(cmd)
09:06:27 web.1            |   File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
09:06:27 web.1            |     return frappe.call(method, **frappe.form_dict)
09:06:27 web.1            |   File "apps/frappe/frappe/__init__.py", line 1620, in call
09:06:27 web.1            |     return fn(*args, **newargs)
09:06:27 web.1            |   File "apps/frappe/frappe/__init__.py", line 808, in wrapper_fn
09:06:27 web.1            |     retval = fn(*args, **get_newargs(fn, kwargs))
09:06:27 web.1            |   File "apps/frappe/frappe/desk/reportview.py", line 29, in get
09:06:27 web.1            |     data = compress(execute(**args), args=args)
09:06:27 web.1            |   File "apps/frappe/frappe/desk/reportview.py", line 65, in execute
09:06:27 web.1            |     return DatabaseQuery(doctype).execute(*args, **kwargs)
09:06:27 web.1            |   File "apps/frappe/frappe/model/db_query.py", line 201, in execute
09:06:27 web.1            |     result = self.build_and_run()
09:06:27 web.1            |   File "apps/frappe/frappe/model/db_query.py", line 241, in build_and_run
09:06:27 web.1            |     return frappe.db.sql(
09:06:27 web.1            |   File "apps/frappe/frappe/database/database.py", line 220, in sql
09:06:27 web.1            |     self._cursor.execute(query, values)
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
09:06:27 web.1            |     result = self._query(query)
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
09:06:27 web.1            |     conn.query(q)
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
09:06:27 web.1            |     self._affected_rows = self._read_query_result(unbuffered=unbuffered)
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
09:06:27 web.1            |     result.read()
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
09:06:27 web.1            |     first_packet = self.connection._read_packet()
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
09:06:27 web.1            |     packet.raise_for_error()
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
09:06:27 web.1            |     err.raise_mysql_exception(self._data)
09:06:27 web.1            |   File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
09:06:27 web.1            |     raise errorclass(errno, errval)
09:06:27 web.1            | pymysql.err.OperationalError: (1054, "Unknown column 'tabMitarbeiterKosten.stundenlohn_1_db1' in 'field list'")

Additional information

OS version / distribution, Frappe install method, etc.
debian bullseye, manual install

@zongo811 zongo811 added the bug label Feb 1, 2024
@ankush
Copy link
Member

ankush commented Feb 1, 2024

Virtual fields are not supported in list view. List view fetches using SQL and you can't evaluate virtual fields using SQL.

@ankush ankush added the valid label Feb 1, 2024
@ankush ankush reopened this Feb 1, 2024
@ankush ankush closed this as completed Feb 1, 2024
@ankush ankush reopened this Feb 1, 2024
@ankush ankush closed this as completed Feb 1, 2024
@ankush ankush reopened this Feb 1, 2024
@ankush ankush closed this as completed Feb 1, 2024
@ankush ankush reopened this Feb 1, 2024
@ankush ankush closed this as completed Feb 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2024
@frappe-pr-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 14.76.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants