inqlik / inqlik-tools

Set of tools for QlikView development in Sublime Text 3
54 stars 15 forks source link

QVD viewer needs to quote fields with strings #7

Open kmpm opened 9 years ago

kmpm commented 9 years ago

When the qvd viewer creates a sample load statement it would be helpful if it quoted fields needing it. I the example below Qty_ per Unit of Measure needs to be "Qty_ per Unit of Measure" or possible as I prefer it [Qty_ per Unit of Measure]

LOAD
  Item No_,
  Code,
  Qty_ per Unit of Measure,
  Length,
  Width,
  Height,
  Cubage,
  Weight
    FROM [C:\path\to\some\file.qvd] (QVD);
vadimtsushko commented 9 years ago

Good catch, Peter. Thank you. I'll look at this. BTW, that project of you - node-qvx, very very interesting. I've always wanted to do this in Dart, maybe I'll try to port it someday

kmpm commented 9 years ago

I use that one to create data for qv from a readstream generated from a mongodb. Works perfectly.

vadimtsushko commented 9 years ago

Wow, mongodb :) Once I wrote native mongodb driver for dart. Regarding your proposal, do you know the best way to assess when quoting is needed? Currently I think to quote field names if then contains any of [' ','.',','%','#'] characters. Something else? I'll better do not whitelist only ascii chars and digits in field names as I've found that field names with non-Latin characters works perfectly without quoting in QV scripts. (I mean field names like Сумма or Себестоимость for example)

kmpm commented 9 years ago

I have not found a good source to what characters need to be quoted but https://community.qlik.com/blogs/qlikviewdesignblog/2013/04/09/quoteology mentions plus and minus as well as those you listed.

And I have found one occation where the field contained [] so I had to use " as qoutes instead of my regular ones so it basically needs to solve quoting of quotes or escaping them somehow.

kmpm commented 9 years ago

Instead of detecting if a quote is needed I would quote everything.

I would basically quote everything in something like [ ] and if the field does contain one of those fields fall back to double quotes and if it contains that as well fall back to grave accents (ascii 96). That would probably cover >99% of the cases.

vadimtsushko commented 9 years ago

Well, that is a valid approach. If I recall it correctly QVDViewer by Dmitry Gudkov does just it. There is a small problem though, I personally hate any quotes in my field lists and consequently try to keep fields names in a form valid without quotes. I think I would add a setting in package settings (something like always_quote_fields) and would behave accordingly with that setting.