Skip to content

Getting same results for both eq and neq clauses #102

Open
@serpro69

Description

@serpro69

data:

{
  "appStatus": {
    "displayName": "JobServer",
    "instanceStatus": {
      "autoRestartSuspended": false,
      "autoRestartSuspendedForApp": false,
      "autoRestartableApp": false,
      "instance": {
        "active": true,
        "applicationDisplayName": "JobServer",
        "applicationId": 42,
        "applicationName": "JobServer",
        "custom": false,
        "id": 10,
        "name": 1,
        "serverName": "xxx"
      },
      "lastStartTime": "2022-11-06 11:53:52",
      "lastStatusChangeTime": "2022-12-14 16:37:31",
      "lastStatusEvent": "Stop",
      "lastStopTime": "2022-12-14 16:37:31",
      "status": "STOPPED"
    },
    "name": "JobServer",
    "numberOfInstancesDown": 1,
    "numberOfInstancesRunning": 0,
    "outageCountInLast24Hrs": 1,
    "pecentageUpInstance": 0,
    "status": "Red",
    "totalNumberOfInstances": 1
  }
}

code:

notStopped := jq.New().File("out.json").
	From("appStatus.instanceStatus").
	Where("status", "neq", "STOPPED")

log.Println(notStoppped)
log.Println(notStopped.Get())

output:

Content: {
  "appStatus": {
    "displayName": "JobServer",
    "instanceStatus": {
      "autoRestartSuspended": false,
      "autoRestartSuspendedForApp": false,
      "autoRestartableApp": false,
      "instance": {
        "active": true,
        "applicationDisplayName": "JobServer",
        "applicationId": 42,
        "applicationName": "JobServer",
        "custom": false,
        "id": 10,
        "name": 1,
        "serverName": "xxx"
      },
      "lastStartTime": "2022-11-06 11:53:52",
      "lastStatusChangeTime": "2022-12-14 16:37:31",
      "lastStatusEvent": "Stop",
      "lastStopTime": "2022-12-14 16:37:31",
      "status": "STOPPED"
    },
    "name": "JobServer",
    "numberOfInstancesDown": 1,
    "numberOfInstancesRunning": 0,
    "outageCountInLast24Hrs": 1,
    "pecentageUpInstance": 0,
    "status": "Red",
    "totalNumberOfInstances": 1
  }
}

Queries:[[{status eq STOPPED}]]

2022/12/14 20:48:31 map[autoRestartSuspended:false autoRestartSuspendedForApp:false autoRestartableApp:false instance:map[active:true applicationDisplayName:JobServer applicationId:42 applicationName:JobServer custom:false id:10 name:1 serverName:xxx] lastStartTime:2022-11-06 11:53:52 lastStatusChangeTime:2022-12-14 16:37:31 lastStatusEvent:Stop lastStopTime:2022-12-14 16:37:31 status:STOPPED]

Changing where to eq produces exactly same output.
I would think that neq should return an empty map instead?

Another test with neq:

notStopped := jq.New().File("out.json").
	From("appStatus").
	From("instanceStatus.instance").
	Where("name", "!=", 1)

Returns:

map[active:true applicationDisplayName:JobServer applicationId:42 applicationName:JobServer custom:false id:10 name:1 serverName:xxx]

So it would appear that neq and != do not work as expected?

Any help in getting this working? Am I doing smth wrong?

PS: is this lib maintained? Seems like not much activity going on lately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions