Inserting boolean value in questdb node shows error when value is false

I have two workflows. First one receives some satellite information through an http node and passes this to an mqtt broker. Second one receives this data using MQTT trigger and passes this to questdb. In the questdb node, I am using the insert option. The data is being inserted as long as the boolean field shows value true. But when it turns false, I am getting the following error.

error: Expression expected
{
  "name": "Recvr",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        510,
        290
      ]
    },
    {
      "parameters": {
        "topics": "space-objects/satellites/iss",
        "options": {
          "jsonParseBody": true,
          "onlyMessage": true
        }
      },
      "name": "MQTT Trigger - ISS Satellite",
      "type": "n8n-nodes-base.mqttTrigger",
      "typeVersion": 1,
      "position": [
        760,
        300
      ],
      "credentials": {
        "mqtt": "test"
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO satellites\nVALUES (\n'{{$json[\"info\"][\"satname\"]}}',\n{{$json[\"info\"][\"satid\"]}},\n{{$json[\"info\"][\"transactionscount\"]}},\n{{$json[\"positions\"][0][\"satlatitude\"]}},\n{{$json[\"positions\"][0][\"satlongitude\"]}},\n{{$json[\"positions\"][0][\"sataltitude\"]}},\n{{$json[\"positions\"][0][\"azimuth\"]}},\n{{$json[\"positions\"][0][\"elevation\"]}},\n{{$json[\"positions\"][0][\"ra\"]}},\n{{$json[\"positions\"][0][\"dec\"]}},\n{{$json[\"positions\"][0][\"timestamp\"]}},\n{{$json[\"positions\"][0][\"eclipsed\"]}}\n);",
        "additionalFields": {}
      },
      "name": "QuestDB",
      "type": "n8n-nodes-base.questDb",
      "typeVersion": 1,
      "position": [
        980,
        300
      ],
      "credentials": {
        "questDb": "QuestDB account 3"
      }
    }
  ],
  "connections": {
    "MQTT Trigger - ISS Satellite": {
      "main": [
        [
          {
            "node": "QuestDB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 76
}

How can I fix this?

Thank you.

Hi @Dhanya_V_Sagar, I quickly tested inserting a false boolean value into quest db using the node and didn’t run into trouble here. Both true and false values got inserted as expected:

So I suspect it might have to do with the exact data you are using on your end. Would you be able to share the data returned by your MQTT Trigger - ISS Satellite node and also confirm the version of n8n you are using?

Many thanks!

This is the data I am receiving

[
{
"info": {
"satname": "SPACE STATION",
"satid": 25544,
"transactionscount": 659
},
"positions": [
{
"satlatitude": 32.18860169,
"satlongitude": -119.27787606,
"sataltitude": 421.51,
"azimuth": 268.85,
"elevation": -12.02,
"ra": 151.66341406,
"dec": -8.63346952,
"timestamp": 1641480037,
"eclipsed": false
},
{
"satlatitude": 32.14444116,
"satlongitude": -119.22629979,
"sataltitude": 421.5,
"azimuth": 268.75,
"elevation": -12.01,
"ra": 151.74301855,
"dec": -8.70110243,
"timestamp": 1641480038,
"eclipsed": false
}
]
}
]

Version of n8n 0.141.1.

Thank you

Thanks, I was now able to see the problem. For v0.141.1, you could just use an expression like {{$json["positions"][0]["eclipsed"].toString()}} in your QuestDB node. This would convert the boolean value into a string which doesn’t cause any trouble.

@MutedJam

Thank you !!! It works. I have one more doubt. In the second workflow, the execution stops when the MQTT trigger node receives the first set of value and pass it to next node. I have multiple set sof data being published to the broker. But I am receiving only first set of value. I tried by keeping the workflow active, but it’s not receiving any data.

Hi @Dhanya_V_Sagar, I am not sure I fully understand the problem. Is the workflow deactivating itself after running once? Or are you saying the QuestDB node just processes the first item it receives each time the workflow is triggered?

Sorry for the lack of clarity. I have 2 pictures added. The MQTT node in the first picture is publishing data continuously to a broker. The MQTT trigger node in the second picture captures only the first data (not the ones coming after the first).The workflow then stops execution.

I had manually executed the workflow
I tried by toggling the active button to true. It’s not capturing the data.


Hi @Dhanya_V_Sagar, just to make sure I am not missing anything here - after toggling a workflow “Active” you wouldn’t see data coming into your canvas in real time (like you would when clicking “Execute Workflow”).

Instead, production data would only be stored if you have enabled this in the workflow settings:

You can then access previous workflow executions via the Executions list available through the sidebar on the left:
image

To inspect the data of an individual execution, you can then use this button: