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

Getting same results for both eq and neq clauses #102

Open
serpro69 opened this issue Dec 14, 2022 · 0 comments
Open

Getting same results for both eq and neq clauses #102

serpro69 opened this issue Dec 14, 2022 · 0 comments

Comments

@serpro69
Copy link

serpro69 commented Dec 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant