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

[Bug] Attribute Table Manager fails with TEXT data column containing newline #2635

Open
nilason opened this issue Nov 7, 2022 · 3 comments
Labels
bug Something isn't working GUI wxGUI related Python Related code is in Python

Comments

@nilason
Copy link
Contributor

nilason commented Nov 7, 2022

Describe the bug

Attempt to open Attribute Table Manager for a layer with TEXT data column containing newline throws an exception:

Error
Unable to read the table <blobtest> from the database due to seemingly inconsistent number of columns in the data transfer. Check row: "a": "10",... Likely, a newline character is present in the attribute value starting with: '"a": "10",' Use the v.db.select module to investigate.

Reason: Unable to read the table <blobtest> from the database due to seemingly inconsistent number of columns in the data transfer. Check row: "a": "10",... Likely, a newline character is present in the attribute value starting with: '"a": "10",' Use the v.db.select module to investigate.

Traceback (most recent call last):
File "/dev/grass/dist.aarch64-apple-darwin21.6.0/gui/wxpython/dbmgr/base.py", line 129, in __init__
keyColumn = self.LoadData(layer)
File "/dev/grass/dist.aarch64-apple-darwin21.6.0/gui/wxpython/dbmgr/base.py", line 325, in LoadData
raise GException(
core.gcmd.GException: Unable to read the table <blobtest> from the database due to seemingly inconsistent number of columns in the data transfer. Check row: "a": "10",... Likely, a newline character is present in the attribute value starting with: '"a": "10",' Use the v.db.select module to investigate.

The data table:

v.db.select  blobtest
cat|ID_int32|ID_int64|date_time|json
1|1|20|2022-11-16 00:00:00|{
    "a": "10",
    "b": "20",
    "c": "30"
}

db.describe blobtest
...
column:json
description:
type:TEXT
len:1000
scale:0
precision:0
default:
nullok:yes
select:?
update:?

To Reproduce
Steps to reproduce the behavior:

  1. Using v.in.ogr: skip columns with unsupported data type instead of failing to import #2630
  2. Import data, see [Bug] v.in.ogr: handle columns with unsupported datatype in GRASS DBMI #2628 (comment)
  3. In GUI, choose "Show Attribute data" in Layers panel.

Expected behavior
Attribute table should open without exception.
Possible solution for the TEXT fields:
a) Non-editable with a eg. '<TEXT>' stand-in displayed.
b) Contains button which opens a mini text edit window, enabling editing and or viewing.

System description (please complete the following information):

  • Operating System: all
  • GRASS GIS version 8
@nilason nilason added bug Something isn't working GUI wxGUI related Python Related code is in Python labels Nov 7, 2022
@marisn
Copy link
Contributor

marisn commented Nov 7, 2022

This is not the only place where code fails on a newline: #2576

@ninsbl
Copy link
Member

ninsbl commented Nov 7, 2022

Note: The column "json" was created to test support for JSON data in SQLite. JSON-support in SQLite has recently been further improved:
https://tirkarthi.github.io/programming/2022/02/26/sqlite-json-improvements.html

@wenzeslaus
Copy link
Member

The parsing in GUI was written before there was JSON and real CSV outputs in v.db.select. Basically the same story as for vector_db_select (#2576). db.select may need these too in order to fix the GUI code.

The error originates here: https://github.com/OSGeo/grass/blob/main/gui/wxpython/dbmgr/base.py#L317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

No branches or pull requests

4 participants