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]: Special characters on column names affects dv query #375

Closed
brandonkboswell opened this issue Sep 13, 2022 · 15 comments
Closed

[BUG]: Special characters on column names affects dv query #375

brandonkboswell opened this issue Sep 13, 2022 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@brandonkboswell
Copy link

brandonkboswell commented Sep 13, 2022

Contact Details

brandonkboswell@gmail.com

Present your request

I want to see a query example in the docs when setting up a new database. I am trying to create dashboards for specific folders (without having to have the database in those folders), but I can't seem to get the syntax right or find a good example. I'm trying FROM "2. areas" and it says it is valid, but when I go to open the database I get an error obtaining query result, using current folder instead

For which platform do you request this request??

Desktop

@brandonkboswell brandonkboswell added enhancement New feature or request triage Issue not tagged yet. talking to the user labels Sep 13, 2022
@imeed166 imeed166 added bug Something isn't working and removed enhancement New feature or request labels Sep 13, 2022
@imeed166
Copy link
Collaborator

Used the query source, with a similar FROM "folder" and it worked for me, on version 2.5.3. Make sure to use copy file path command to get the folder name. As this is a possible bug, I will change the label.

As for the example in the docs, I'll add one, thanks for the suggestion.

@imeed166 imeed166 changed the title [FR]: Add a query example to the docs [FR]: query source not working Sep 13, 2022
@brandonkboswell
Copy link
Author

I have a folder named  2. areas. When I copy file path, I get "2. areas". When I put that into the query as FROM "2. areas"I get errors.

image

@RafaelGB
Copy link
Owner

I am trying to reproduce your case but it woks fine

Could you share your markdown database file?

another possibility is that the query does not work itself. try it out of the plugin with a simple

'''dataview
TABLE file FROM "2. areas"
'''
Screen.Recording.2022-09-13.at.18.52.37.mov

@brandonkboswell
Copy link
Author

The Dataview query works. This is my Markdown file.

`---

database-plugin: basic


%% dbfolder:yaml
name: Area Dashboard
description:
columns:
file:
key: "file"
input: "markdown"
label: "File"
accessorKey: "file"
isMetadata: true
skipPersist: false
isDragDisabled: false
csvCandidate: true
width: 329
isHidden: false
sortIndex: -1
config:
enable_media_view: true
media_width: 100
media_height: 100
isInline: true
task_hide_completed: true
tasks:
key: "tasks"
input: "task"
label: "Task"
accessorKey: "tasks"
isMetadata: true
isDragDisabled: false
skipPersist: false
csvCandidate: false
width: 484
isHidden: false
sortIndex: -1
config:
enable_media_view: true
media_width: 100
media_height: 100
isInline: false
task_hide_completed: true
2022-Q3:
input: "select"
accessorKey: "2022-Q3"
key: "2022-Q3"
label: "2022-Q3"
position: 100
skipPersist: false
isHidden: false
width: 109
sortIndex: -1
options:
- { label: "On Track", backgroundColor: "hsl(106, 95%, 90%)"}
- { label: "Slipping", backgroundColor: "hsl(37.42857142857143,91.30434782608697%,54.90196078431373%)"}
config:
enable_media_view: true
media_width: 100
media_height: 100
isInline: false
task_hide_completed: true
config:
remove_field_when_delete_column: false
cell_size: compact
sticky_first_column: true
group_folder_column:
show_metadata_created: false
show_metadata_modified: false
show_metadata_tasks: true
source_data: query
source_form_result: "FROM "2. areas""
frontmatter_quote_wrap: false
row_templates_folder: /
current_row_template:
pagination_size: 145
show_metadata_inlinks: false
show_metadata_outlinks: false
source_destination_path: 2. areas
filters:
enabled: false
conditions:
%%`

@RafaelGB
Copy link
Owner

RafaelGB commented Sep 13, 2022

The problem here is how is saved.

Instead "\"your folder\"". The yaml is saved without the \

Which version of the plugin are you using?

@brandonkboswell
Copy link
Author

brandonkboswell commented Sep 13, 2022 via email

@RafaelGB
Copy link
Owner

With that version should be saved fine. Hmm

Try to modify manually the query property (source_form_result)

With "FROM \"2. areas\""

This week I will release a new version with another things, maybe I fixed something about because I can not reproduce it =( thanks for your report

@brandonkboswell
Copy link
Author

Hey Rafael, weirdly when I go into the markdown file the source_form_result already is that. Here's a Loom in case I'm doing something wrong: https://www.loom.com/share/28c4830ca3724d7dba140f1ddb6f4cb9

@RafaelGB
Copy link
Owner

I think I have found the problem with your query. The naming of your 2022-Q3 breaks the call. I have to investigate why

Try with another naming or rename manually the key,id... of the column less the label

The plugin use the id/key to construct the query

@brandonkboswell
Copy link
Author

You appear to be correct. Renaming to Q32022 appears to work. Thanks!

@RafaelGB
Copy link
Owner

nice! I will check the reason about the problem with - in the names.

@RafaelGB RafaelGB removed the triage Issue not tagged yet. talking to the user label Sep 14, 2022
@RafaelGB RafaelGB added this to 🥶 backlog in Obsidian database plugin Roadmap via automation Sep 14, 2022
@RafaelGB RafaelGB changed the title [FR]: query source not working [BUG]: Special characters on column names affects dv query Sep 14, 2022
@brandonkboswell
Copy link
Author

Interestingly, I still run into the issue with '2022Q3', so I think it might have more to do with the leading year than the dash

@RafaelGB
Copy link
Owner

Fixed! will be available with the next version =)

export function generateDataviewTableQuery(columns: TableColumn[], fromQuery: string): string {
    return `TABLE ${columns
        .filter((col) => !col.isMetadata)
        .map((col) => `"${col.key}"`) // Added quotes to every column name to fix it
        .join(",")},${DatabaseCore.DATAVIEW_FILE},${DatabaseCore.FRONTMATTER_KEY} ${fromQuery}`
}

@RafaelGB RafaelGB moved this from 🥶 backlog to 🏁👍 Ready for the next version in Obsidian database plugin Roadmap Sep 14, 2022
@brandonkboswell
Copy link
Author

Thank you, @RafaelGB, for the wonderful plugin and support!

@RafaelGB
Copy link
Owner

okey looks like a bug with the DV api, Your field can not start with a number...

Anyway I will release a minor version where you can see on console log "info"lvl the entire query

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

3 participants