dasel icon indicating copy to clipboard operation
dasel copied to clipboard

Whitespacing issues

Open iilyak opened this issue 3 years ago • 1 comments

Describe the bug Adding whitespace to format the query in a readable way brakes the functionality

To Reproduce Steps to reproduce the behavior:

  1. Create test.drawio.xml file as described bellow
  2. Issue the same query with different formatting
  3. Observe difference in behaviour
cat test.drawio.xml
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="Electron" modified="2022-12-27T16:51:00.393Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.7.4 Chrome/106.0.5249.199 Electron/21.3.3 Safari/537.36" etag="Chvfh0pmRcsiRFeLGn84" version="20.7.4" type="device">
  <diagram id="DIBkk8TONfjRhfH_ZR78" name="Page-1">
    <mxGraphModel dx="1114" dy="878" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="850" math="0" shadow="0">
      <root>
        <mxCell id="0"/>
        <mxCell id="1" parent="0"/>
        <object label="" my_property="324" my_string="hello" id="vs0W597VZl1qWhmtER3h-1">
          <mxCell style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
            <mxGeometry x="100" y="200" width="120" height="60" as="geometry"/>
          </mxCell>
        </object>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

queries

working

❯ dasel -f test.drawio.xml -w json 'mxfile.diagram.mxGraphModel.root.all()
    .filter(and(equal(type(),object),equal(-my_property,324)))'

{
  "-id": "vs0W597VZl1qWhmtER3h-1",
  "-label": "",
  "-my_property": "324",
  "-my_string": "hello",
  "mxCell": {
    "-parent": "1",
    "-style": "rounded=0;whiteSpace=wrap;html=1;",
    "-vertex": "1",
    "mxGeometry": {
      "-as": "geometry",
      "-height": "60",
      "-width": "120",
      "-x": "100",
      "-y": "200"
    }
  }
}

not working

❯ dasel -f test.drawio.xml -w json 'mxfile.diagram.mxGraphModel.root
    .all()
    .filter(and(equal(type(),object),equal(-my_property,324)))'
❯ dasel -f test.drawio.xml -w json 'mxfile.diagram.mxGraphModel.root
  .all()
  .filter(
    and(
      equal(type(),object),
      equal(-my_property,324)
    )
  )'
dasel -f test.drawio.xml -w json 'mxfile.diagram.mxGraphModel.root.all()
  .filter(
    and(
      equal(type(),object),
      equal(-my_property,324)
    )
  )'

Expected behavior I expect the same outpput regardless of query format

Desktop (please complete the following information):

  • OS: MacOS (M1)
  • Version: dasel version 2.0.2

iilyak avatar Dec 29 '22 17:12 iilyak

This is a known limitation right now.

I'll keep this issue open in the meantime while I work on a fix.

TomWright avatar Dec 30 '22 12:12 TomWright