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

fix: ignore virtual doctypes during data export #20891

Merged
merged 1 commit into from
May 4, 2023

Conversation

Alchez
Copy link
Contributor

@Alchez Alchez commented May 4, 2023

Trying to export records for doctypes that have a child table as a virtual doctype raises the following error:

ProgrammingError: (1146, "Table '_0ece7759525955dd.tab{redacted}' doesn't exist")
  File "frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "__init__.py", line 1585, in call
    return fn(*args, **newargs)
  File "frappe/core/doctype/data_export/exporter.py", line 61, in export_data
    exporter.build_response()
  File "frappe/core/doctype/data_export/exporter.py", line 141, in build_response
    self.add_data()
  File "frappe/core/doctype/data_export/exporter.py", line 379, in add_data
    for ci, child in enumerate(data_row.run(as_dict=True)):
  File "frappe/query_builder/utils.py", line 76, in execute_query
    return frappe.db.sql(query, params, *args, **kwargs)  # nosemgrep
  File "frappe/database/database.py", line 206, in sql
    self._cursor.execute(query, values)
  File "pymysql/cursors.py", line 148, in execute
    result = self._query(query)
  File "pymysql/cursors.py", line 310, in _query
    conn.query(q)
  File "pymysql/connections.py", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "pymysql/connections.py", line 775, in _read_query_result
    result.read()
  File "pymysql/connections.py", line 1156, in read
    first_packet = self.connection._read_packet()
  File "pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)

In another iteration, we could use a common controller method to add the rows instead.

@github-actions github-actions bot added the add-test-cases Add test case to validate fix or enhancement label May 4, 2023
@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #20891 (2517648) into develop (4b7c735) will increase coverage by 0.00%.
The diff coverage is 66.66%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #20891   +/-   ##
========================================
  Coverage    63.89%   63.89%           
========================================
  Files          761      761           
  Lines        68821    68824    +3     
  Branches      6219     6219           
========================================
+ Hits         43970    43975    +5     
+ Misses       21309    21307    -2     
  Partials      3542     3542           
Flag Coverage Δ
server 68.92% <66.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ankush ankush merged commit 01a0a0f into frappe:develop May 4, 2023
17 of 19 checks passed
@ankush ankush added the backport version-14-hotfix backport to version 14 label May 4, 2023
mergify bot pushed a commit that referenced this pull request May 4, 2023
@Alchez Alchez deleted the dev-virtual-doctype-export branch May 4, 2023 13:33
phot0n pushed a commit that referenced this pull request May 4, 2023
(cherry picked from commit 01a0a0f)

Co-authored-by: Rohan <Alchez@users.noreply.github.com>
frappe-pr-bot pushed a commit that referenced this pull request May 9, 2023
# [14.36.0](v14.35.0...v14.36.0) (2023-05-09)

### Bug Fixes

* ensure that `get_last_email` returns the most recent email (backport [#20711](#20711)) ([624f96b](624f96b))
* escape html from listview row title ([56bec1d](56bec1d))
* escape html from workspace title ([e68fc43](e68fc43))
* ignore virtual doctypes during data export ([#20891](#20891)) ([#20899](#20899)) ([d6bfaae](d6bfaae))
* make operator in link filters translatable (backport [#20884](#20884)) ([#20911](#20911)) ([1ec3bad](1ec3bad))
* message.py executing script ([#20887](#20887)) ([#20897](#20897)) ([1bcf5d4](1bcf5d4))
* **multi-pdf:** change response type to pdf ([997559c](997559c))
* **oauth:** add exp to idToken ([#20694](#20694)) ([#20903](#20903)) ([1a8e671](1a8e671))
* reload communication before re-save ([#20914](#20914)) ([#20921](#20921)) ([37a8ec0](37a8ec0))
* set default letterhead and print format ([a5a6965](a5a6965))
* strip comma, space from recipients before sending email for auto repeat ([#20940](#20940)) ([#20945](#20945)) ([042a1d2](042a1d2))
* translate lowercase operators to german ([#20912](#20912)) ([#20916](#20916)) ([c47b146](c47b146))
* type hints for get_address_display ([#20923](#20923)) ([#20924](#20924)) ([15df963](15df963))
* use smaller font only if the report doesnt have a standard print format ([#20878](#20878)) ([#20947](#20947)) ([35165d0](35165d0))

### Features

* helper method for address display ([#20900](#20900)) ([#20901](#20901)) ([f914770](f914770))
* telemetry using posthog (backport [#20825](#20825)) ([#20934](#20934)) ([bbe29ee](bbe29ee))

### Performance Improvements

* get all file data at once when downloading private file ([#20902](#20902)) ([e106594](e106594))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
add-test-cases Add test case to validate fix or enhancement backport version-14-hotfix backport to version 14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants