{"id":37417283,"url":"https://github.com/bonkzero404/gojson2sql","last_synced_at":"2026-01-16T06:02:23.805Z","repository":{"id":217890818,"uuid":"745044844","full_name":"bonkzero404/gojson2sql","owner":"bonkzero404","description":"GoJson2SQL which means GoLang Json to SQL parser","archived":false,"fork":false,"pushed_at":"2024-03-13T22:33:14.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T19:56:44.558Z","etag":null,"topics":["convert","jql","json","parser","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bonkzero404.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-18T14:34:09.000Z","updated_at":"2024-01-19T07:20:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e795c48-38a4-47a1-912a-64b3f8923ff7","html_url":"https://github.com/bonkzero404/gojson2sql","commit_stats":null,"previous_names":["bonkzero404/gojson2sql"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/bonkzero404/gojson2sql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonkzero404%2Fgojson2sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonkzero404%2Fgojson2sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonkzero404%2Fgojson2sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonkzero404%2Fgojson2sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bonkzero404","download_url":"https://codeload.github.com/bonkzero404/gojson2sql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonkzero404%2Fgojson2sql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convert","jql","json","parser","sql"],"created_at":"2026-01-16T06:02:23.677Z","updated_at":"2026-01-16T06:02:23.754Z","avatar_url":"https://github.com/bonkzero404.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoJSON2SQL\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/bonkzero404/gojson2sql)](https://goreportcard.com/report/github.com/bonkzero404/gojson2sql)\n[![codecov](https://codecov.io/gh/bonkzero404/gojson2sql/branch/main/graphs/badge.svg?branch=main)](https://codecov.io/gh/bonkzero404/gojson2sql)\n[![build-status](https://github.com/bonkzero404/gojson2sql/workflows/Go/badge.svg)](https://github.com/bonkzero404/gojson2sql/actions)\n\nGoJson2SQL is a library for composing SQL queries using JSON. A JSON file is transformed into an SQL string. This library facilitates the process of generating SQL statements by utilizing a structured JSON format, enhancing the readability and simplicity of SQL query construction.\n\n## Limitations\n\nCurrently, it can only perform **SELECT** queries.\n\n## Features\n\n- Basic select query\n- Basic selection field\n- Join Table\n- Conditional (WHERE Statement)\n- HAVING\n- SQL Function\n- CASE, WHEN and THEN in the selection fields\n- Subqueries\n- Parsing Value to Parameters\n- SQLi Prevention (Experimental)\n\n## TODO:\n\n- More Queries\n- Validate SQL Syntax\n- ?\n\n## Installation\n\n```\ngo get github.com/bonkzero404/gojson2sql\n```\n\n## Simple Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/bonkzero404/gojson2sql\"\n)\n\nfunc main() {\n  sqlJson := `\n    {\n      \"table\": \"table_1\",\n      \"selectFields\": [\n        \"a\",\n        \"b\"\n      ],\n      \"conditions\": [\n        {\n          \"datatype\": \"number\",\n          \"clause\": \"a\",\n          \"operator\": \"=\",\n          \"value\": 1\n        }\n      ],\n      \"limit\": 1\n    }\n  `\n  jql, err := gojson2sql.NewJson2Sql([]byte(sqlJson), \u0026gojson2sql.Json2SqlConf{})\n  if err != nil {\n    panic(err)\n  }\n\n  sql, param, _ := jql.Generate()\n\n  fmt.Println(\"SQL:\", sql)\n  fmt.Println(\"Param:\", param)\n}\n```\n\nOutput:\n\n```sql\nSQL: SELECT a, b FROM table_1 WHERE a = ? LIMIT\nParam: [1]\n```\n\nYou can use this raw SQL with either the sql package or GORM. Here's an example with sql package:\n\n```go\njql, _ := gojson2sql.NewJson2Sql([]byte(sqlJson), \u0026gojson2sql.Json2SqlConf{})\nsql, param, _ := jql.Generate()\n\ndb.Query(sql, param)\n```\n\n## Example Union Query Operation\n\n```json\n[\n  {\n    \"table\": \"table_1\",\n    \"selectFields\": [\"a\", \"b\"],\n    \"conditions\": [\n      {\n        \"datatype\": \"number\",\n        \"clause\": \"a\",\n        \"operator\": \"=\",\n        \"value\": 1\n      }\n    ],\n    \"limit\": 1\n  },\n  {\n    \"table\": \"table_2\",\n    \"selectFields\": [\"a\", \"b\"],\n    \"conditions\": [\n      {\n        \"datatype\": \"number\",\n        \"clause\": \"a\",\n        \"operator\": \"=\",\n        \"value\": 1\n      }\n    ],\n    \"limit\": 1\n  }\n]\n```\n\nIf you are using **UNION**, you must set the withUnion parameter in Json2SqlConf. Here is an example:\n\n```go\njql, _ := gojson2sql.NewJson2Sql([]byte(sqlJson), \u0026gojson2sql.Json2SqlConf{\n  withUnion: true,\n})\nsql, param, _ := jql.Generate()\n\ndb.Query(sql, param)\n```\n\nOutput:\n\n```sql\nSELECT a, b FROM table_1 WHERE a = 1 LIMIT 1 UNION SELECT a, b FROM table_2 WHERE a = 1 LIMIT 1\n```\n\nYou can see the difference between a union query and a standard select. In a union, you must use a JSON array with the standard JSON format as before.\n\n## Config Parameters\n\n```go\nwithUnion              bool\nwithSanitizedInjection bool\n```\n\n**withUnion**: It is used to set the query to union and the structure must be of array type.\n\n**withSanitizedInjection**: This is an experimental feature, it is far from perfect, and it serves to validate SQL strings against SQL Injection.\n\n## Operator Lists\n\n```go\nconst (\n\tEqual        SQLOperatorEnum = \"=\"\n\tNotEqual     SQLOperatorEnum = \"\u003c\u003e\"\n\tLessThan     SQLOperatorEnum = \"\u003c\"\n\tLessEqual    SQLOperatorEnum = \"\u003c=\"\n\tGreaterThan  SQLOperatorEnum = \"\u003e\"\n\tGreaterEqual SQLOperatorEnum = \"\u003e=\"\n\tLike         SQLOperatorEnum = \"LIKE\"\n\tIlike        SQLOperatorEnum = \"ILIKE\"\n\tBetween      SQLOperatorEnum = \"BETWEEN\"\n\tNotLike      SQLOperatorEnum = \"NOT LIKE\"\n\tIn           SQLOperatorEnum = \"IN\"\n\tNotIn        SQLOperatorEnum = \"NOT IN\"\n\tIsNull       SQLOperatorEnum = \"IS NULL\"\n\tIsNotNull    SQLOperatorEnum = \"IS NOT NULL\"\n)\n```\n\n## Datatype Lists\n\n```go\nconst (\n\tBoolean  SQLDataTypeEnum = \"BOOLEAN\"\n\tString   SQLDataTypeEnum = \"STRING\"\n\tNumber   SQLDataTypeEnum = \"NUMBER\"\n\tRaw      SQLDataTypeEnum = \"RAW\"\n\tFunction SQLDataTypeEnum = \"FUNCTION\"\n\tArray    SQLDataTypeEnum = \"ARRAY\"\n)\n```\n\n## isStatic / isField Properties\n\n- isStatic: (boolean)\n  isStatic is used to set the value of the clause. If true, the value will not be parsed to parameters. However, if false, the opposite will occur. This is typically used in where statements.\n\n- isField: (boolean)\n  isField is used to set a field so that it does not use single quotes. For example, if you describe a function and do not use isField, it will look like this: COUNT('field'). However, if you use isField, it will look like this: COUNT(field).\n\n## JSON Format\n\nIn general, the structure of the JSON format used is as follows:\n\n- **_table_**: Used to describe the table name, e.g. table_name (string)\n\n- **selectFields**:\n  Used to select fields from a table, this property uses the **_Array_** type, you can combine **_Array of String_**, and **_Array of Json_**, the example is as follows:\n\n  ```json\n  {\n    \"selectFields\": [\n      \"table_1.a\",\n      {\n        \"field\": \"table_1.b\",\n        \"alias\": \"foo_bar\"\n      },\n      {\n        \"field\": \"table_2.a\",\n        \"alias\": \"baz\",\n        \"subquery\": {\n          \"table\": \"table_4\",\n          \"selectFields\": [\"*\"],\n          \"conditions\": [\n            {\n              \"datatype\": \"number\",\n              \"clause\": \"a\",\n              \"operator\": \"=\",\n              \"value\": 1\n            }\n          ],\n          \"limit\": 1\n        }\n      },\n      \"table_2.b\",\n      \"table_3.a\",\n      \"table_3.b\"\n    ]\n  }\n  ```\n\n  There you can see there is a subquery, you can use a subquery with the same format as its parent, you can also describe a field with an alias in the selection field.\n\n  \u003e **_NOTE:_** If you are using a subquery, you don't need to describe the datatype property\n\n- **_join_**:\n  You can use join to combine multiple tables, an example is as follows:\n\n  ```json\n  {\n    \"join\": [\n      {\n        \"table\": \"table_2\",\n        \"type\": \"join\",\n        \"on\": {\n          \"table_2.a\": \"table_1.a\"\n        }\n      },\n      {\n        \"table\": \"table_3\",\n        \"type\": \"left\",\n        \"on\": {\n          \"table_3.a\": \"table_2.a\"\n        }\n      }\n    ]\n  }\n  ```\n\n- **conditions**:\n  Conditions are used for SQL Where clauses. The structure of these conditions is dynamic; you can use a function, subquery, or composite. Consider the following example:\n  ```json\n  {\n    \"conditions\": [\n      {\n        \"datatype\": \"string\",\n        \"clause\": \"table_1.a\",\n        \"operator\": \"=\",\n        \"value\": \"foo\"\n      },\n      {\n        \"operand\": \"and\",\n        \"datatype\": \"boolean\",\n        \"clause\": \"table_1.b\",\n        \"operator\": \"=\",\n        \"value\": true\n      },\n      {\n        \"operand\": \"and\",\n        \"datatype\": \"function\",\n        \"clause\": \"table_2.a\",\n        \"operator\": \"\u003e\",\n        \"value\": {\n          \"sqlFunc\": {\n            \"name\": \"sum\",\n            \"params\": [100]\n          }\n        }\n      },\n      {\n        \"operand\": \"and\",\n        \"clause\": \"table_2.b\",\n        \"operator\": \"=\",\n        \"value\": {\n          \"subquery\": {\n            \"table\": \"table_4\",\n            \"selectFields\": [\"*\"],\n            \"conditions\": [\n              {\n                \"datatype\": \"number\",\n                \"clause\": \"a\",\n                \"operator\": \"=\",\n                \"value\": 1\n              }\n            ],\n            \"limit\": 1\n          }\n        }\n      },\n      {\n        \"operand\": \"or\",\n        \"composite\": [\n          {\n            \"clause\": \"table_3.a\",\n            \"datatype\": \"string\",\n            \"operator\": \"between\",\n            \"value\": {\n              \"from\": \"2020-01-01\",\n              \"to\": \"2023-01-01\"\n            }\n          },\n          {\n            \"operand\": \"and\",\n            \"datatype\": \"string\",\n            \"clause\": \"table_3.b\",\n            \"operator\": \"=\",\n            \"value\": \"2\"\n          }\n        ]\n      }\n    ]\n  }\n  ```\n- **groupBy**:\n\n  ```json\n  {\n    \"groupBy\": {\n      \"fields\": [\"table_1.a\"]\n    }\n  }\n  ```\n\n- **having**\n  ```json\n  {\n    \"having\": [\n      {\n        \"clause\": {\n          \"sqlFunc\": {\n            \"name\": \"count\",\n            \"isField\": true,\n            \"params\": [\"table_2.a\"]\n          }\n        },\n        \"datatype\": \"number\",\n        \"operator\": \"\u003e\",\n        \"value\": 10\n      }\n    ]\n  }\n  ```\n- **orderBy, limit, offset**:\n  ```json\n  {\n    \"orderBy\": {\n      \"fields\": [\"table_1.a\", \"table_2.a\"],\n      \"sort\": \"asc\"\n    },\n    \"limit\": 1,\n    \"offset\": 0\n  }\n  ```\n  Or you can describe the limit and offset like this\n  ```json\n  {\n    \"offset\": {\n      \"isStatic\": true,\n      \"value\": 10\n    },\n    \"offset\": {\n      \"value\": 10\n    }\n  }\n  ```\n\n## Convert to Raw Query\n\nYou can also convert to raw query without parameters.\n\n```go\njql, err := gojson2sql.NewJson2Sql([]byte(sqlJson), \u0026gojson2sql.Json2SqlConf{})\nif err != nil {\n  panic(err)\n}\n\nsql := jql.Build()\n\nfmt.Println(\"SQL:\", sql)\n```\n\nOutput:\n\n```sql\nSQL: SELECT a, b FROM table_1 WHERE a = 1 LIMIT 1\n```\n\n## Full Example Advance Query\n\n```go\nsqlJson := `\n  {\n    \"table\": \"table_1\",\n    \"selectFields\": [\n      \"table_1.a\",\n      {\n        \"field\": \"table_1.b\",\n        \"alias\": \"foo_bar\"\n      },\n      {\n        \"field\": \"table_2.a\",\n        \"alias\": \"baz\",\n        \"subquery\": {\n          \"table\": \"table_4\",\n          \"selectFields\": [\"*\"],\n          \"conditions\": [\n            {\n              \"datatype\": \"number\",\n              \"clause\": \"a\",\n              \"operator\": \"=\",\n              \"value\": 1\n            }\n          ],\n          \"limit\": 1\n        }\n      },\n      \"table_2.b\",\n      \"table_3.a\",\n      \"table_3.b\"\n    ],\n    \"join\": [\n      {\n        \"table\": \"table_2\",\n        \"type\": \"join\",\n        \"on\": {\n          \"table_2.a\": \"table_1.a\"\n        }\n      },\n      {\n        \"table\": \"table_3\",\n        \"type\": \"left\",\n        \"on\": {\n          \"table_3.a\": \"table_2.a\"\n        }\n      }\n    ],\n    \"conditions\": [\n      {\n        \"datatype\": \"string\",\n        \"clause\": \"table_1.a\",\n        \"operator\": \"=\",\n        \"value\": \"foo\"\n      },\n      {\n        \"operand\": \"and\",\n        \"datatype\": \"boolean\",\n        \"clause\": \"table_1.b\",\n        \"operator\": \"=\",\n        \"value\": true\n      },\n      {\n        \"operand\": \"and\",\n        \"datatype\": \"function\",\n        \"clause\": \"table_2.a\",\n        \"operator\": \"\u003e\",\n        \"value\": {\n          \"sqlFunc\": {\n            \"name\": \"sum\",\n            \"params\": [100]\n          }\n        }\n      },\n      {\n        \"operand\": \"and\",\n        \"clause\": \"table_2.b\",\n        \"operator\": \"=\",\n        \"value\": {\n          \"subquery\": {\n            \"table\": \"table_4\",\n            \"selectFields\": [\"*\"],\n            \"conditions\": [\n              {\n                \"datatype\": \"number\",\n                \"clause\": \"a\",\n                \"operator\": \"=\",\n                \"value\": 1\n              }\n            ],\n            \"limit\": 1\n          }\n        }\n      },\n      {\n        \"operand\": \"or\",\n        \"composite\": [\n          {\n            \"clause\": \"table_3.a\",\n            \"datatype\": \"string\",\n            \"operator\": \"between\",\n            \"value\": {\n              \"from\": \"2020-01-01\",\n              \"to\": \"2023-01-01\"\n            }\n          },\n          {\n            \"operand\": \"and\",\n            \"datatype\": \"string\",\n            \"clause\": \"table_3.b\",\n            \"operator\": \"=\",\n            \"value\": \"2\"\n          }\n        ]\n      }\n    ],\n    \"groupBy\": {\n      \"fields\": [\"table_1.a\"]\n    },\n    \"having\": [\n      {\n        \"clause\": {\n          \"sqlFunc\": {\n            \"name\": \"count\",\n            \"isField\": true,\n            \"params\": [\"table_2.a\"]\n          }\n        },\n        \"datatype\": \"number\",\n        \"operator\": \"\u003e\",\n        \"value\": 10\n      }\n    ],\n    \"orderBy\": {\n      \"fields\": [\"table_1.a\", \"table_2.a\"],\n      \"sort\": \"asc\"\n    },\n    \"limit\": 1,\n    \"offset\": 0\n  }\n`\njql, err := gojson2sql.NewJson2Sql([]byte(sqlJson), \u0026gojson2sql.Json2SqlConf{})\nif err != nil {\n  panic(err)\n}\n\nsql, param, _ := jql.Generate()\n\nfmt.Println(\"SQL:\", sql)\nfmt.Println(\"Param:\", param)\n```\n\noutput:\n\n```sql\nSQL:\nSELECT\n  table_1.a,\n  table_1.b AS foo_bar,\n  (SELECT * FROM table_4 WHERE a = ? LIMIT 1) AS baz,\n  table_2.b,\n  table_3.a,\n  table_3.b\nFROM table_1\n  JOIN table_2 ON table_2.a = table_1.a\n  LEFT JOIN table_3 ON table_3.a = table_2.a\nWHERE\n  table_1.a = ? AND\n  table_1.b = ? AND\n  table_2.a \u003e sum(?) AND\n  table_2.b = (SELECT * FROM table_4 WHERE a = ? LIMIT 1) OR\n  (table_3.a BETWEEN ? AND ? AND table_3.b = ?)\nGROUP BY table_1.a\nHAVING COUNT(table_2.a) \u003e ?\nORDER BY table_1.a, table_2.a ASC\nLIMIT 1\nOFFSET 0\n\nParam:\n[1 foo true 100 1 2020-01-01 2023-01-01 2 10]\n```\n\n## Complete Example JSON\n\n```json\n{\n  \"table\": \"table_1\",\n  \"selectFields\": [\n    {\n      \"field\": \"table_1.a\",\n      \"alias\": \"foo_bar\"\n    },\n    {\n      \"alias\": \"foo_bar_baz\",\n      \"addFunction\": {\n        \"sqlFunc\": {\n          \"name\": \"count\",\n          \"isField\": true,\n          \"params\": [\"table_1.b\"]\n        }\n      }\n    },\n    {\n      \"field\": \"table_2.a\",\n      \"alias\": \"baz\",\n      \"subquery\": {\n        \"table\": \"table_4\",\n        \"selectFields\": [\"*\"],\n        \"conditions\": [\n          {\n            \"datatype\": \"number\",\n            \"clause\": \"a\",\n            \"operator\": \"=\",\n            \"value\": 1\n          }\n        ],\n        \"limit\": 1\n      }\n    },\n    {\n      \"when\": [\n        {\n          \"clause\": \"table_2.b\",\n          \"datatype\": \"number\",\n          \"isStatic\": true,\n          \"operator\": \"\u003e\",\n          \"value\": 100,\n          \"expectation\": {\n            \"datatype\": \"BOOLEAN\",\n            \"isStatic\": true,\n            \"value\": true\n          }\n        }\n      ],\n      \"defaultValue\": {\n        \"isStatic\": true,\n        \"value\": {\n          \"subquery\": {\n            \"table\": \"table_3\",\n            \"selectFields\": [\"*\"],\n            \"conditions\": [\n              {\n                \"datatype\": \"NUMBER\",\n                \"clause\": \"a\",\n                \"operator\": \"=\",\n                \"value\": 1\n              }\n            ],\n            \"limit\": 1\n          }\n        }\n      },\n      \"alias\": \"field_alias\"\n    },\n    \"table_3.a\",\n    \"table_3.b\"\n  ],\n  \"join\": [\n    {\n      \"table\": \"table_2\",\n      \"type\": \"join\",\n      \"on\": {\n        \"table_2.a\": \"table_1.a\"\n      }\n    },\n    {\n      \"table\": \"table_3\",\n      \"type\": \"left\",\n      \"on\": {\n        \"table_3.a\": \"table_2.a\"\n      }\n    }\n  ],\n  \"conditions\": [\n    {\n      \"datatype\": \"string\",\n      \"clause\": \"table_1.a\",\n      \"operator\": \"=\",\n      \"value\": \"foo\"\n    },\n    {\n      \"operand\": \"and\",\n      \"datatype\": \"boolean\",\n      \"clause\": \"table_1.b\",\n      \"operator\": \"=\",\n      \"value\": true\n    },\n    {\n      \"operand\": \"and\",\n      \"datatype\": \"function\",\n      \"clause\": \"table_2.a\",\n      \"operator\": \"\u003e\",\n      \"value\": {\n        \"sqlFunc\": {\n          \"name\": \"sum\",\n          \"params\": [100]\n        }\n      }\n    },\n    {\n      \"operand\": \"and\",\n      \"clause\": \"table_2.b\",\n      \"operator\": \"=\",\n      \"value\": {\n        \"subquery\": {\n          \"table\": \"table_4\",\n          \"selectFields\": [\"*\"],\n          \"conditions\": [\n            {\n              \"datatype\": \"number\",\n              \"clause\": \"a\",\n              \"operator\": \"=\",\n              \"value\": 1\n            }\n          ],\n          \"limit\": 1\n        }\n      }\n    },\n    {\n      \"operand\": \"or\",\n      \"composite\": [\n        {\n          \"clause\": \"table_3.a\",\n          \"datatype\": \"string\",\n          \"operator\": \"between\",\n          \"value\": {\n            \"from\": \"2020-01-01\",\n            \"to\": \"2023-01-01\"\n          }\n        },\n        {\n          \"operand\": \"and\",\n          \"datatype\": \"string\",\n          \"clause\": \"table_3.b\",\n          \"operator\": \"=\",\n          \"value\": \"2\"\n        }\n      ]\n    }\n  ],\n  \"groupBy\": {\n    \"fields\": [\"table_1.a\"]\n  },\n  \"having\": [\n    {\n      \"clause\": {\n        \"sqlFunc\": {\n          \"name\": \"count\",\n          \"isField\": true,\n          \"params\": [\"table_2.a\"]\n        }\n      },\n      \"datatype\": \"number\",\n      \"operator\": \"\u003e\",\n      \"value\": 10\n    }\n  ],\n  \"orderBy\": {\n    \"fields\": [\"table_1.a\", \"table_2.a\"],\n    \"sort\": \"asc\"\n  },\n  \"limit\": {\n    \"isStatic\": true,\n    \"value\": 10\n  },\n  \"offset\": 0\n}\n```\n\noutput:\n\n```sql\nSELECT\n  table_1.a AS foo_bar,\n  COUNT(table_1.b) AS foo_bar_baz,\n  (SELECT * FROM table_4 WHERE a = 1 LIMIT 1) AS baz,\n  CASE\n    WHEN table_2.b \u003e 100 THEN true\n    ELSE (SELECT * FROM table_3 WHERE a = 1 LIMIT 1)\n  END AS field_alias,\n  table_3.a,\n  table_3.b\nFROM table_1\n  JOIN table_2 ON table_2.a = table_1.a\n  LEFT JOIN table_3 ON table_3.a = table_2.a\nWHERE\n  table_1.a = 'foo' AND\n  table_1.b = true AND\n  table_2.a \u003e sum(100) AND\n  table_2.b = (SELECT * FROM table_4 WHERE a = 1 LIMIT 1) OR\n  (table_3.a BETWEEN '2020-01-01' AND '2023-01-01' AND table_3.b = '2')\nGROUP BY table_1.a\nHAVING\n  COUNT(table_2.a) \u003e 10\nORDER BY table_1.a, table_2.a ASC\nLIMIT 10\nOFFSET 0\n```\n\n## Testing\n\n```go\n\u003e go test -v -cover ./...\n=== RUN   TestConstructor\n--- PASS: TestConstructor (0.00s)\n=== RUN   TestConstructor_Fail\n--- PASS: TestConstructor_Fail (0.00s)\n=== RUN   TestConstructor_Fail_Union\n--- PASS: TestConstructor_Fail_Union (0.00s)\n=== RUN   TestRawJson_OK\n--- PASS: TestRawJson_OK (0.00s)\n=== RUN   TestRawJson_Error\n--- PASS: TestRawJson_Error (0.00s)\n=== RUN   TestMaskedQueryValue\n--- PASS: TestMaskedQueryValue (0.00s)\n=== RUN   TestGenerateSelectFrom\n--- PASS: TestGenerateSelectFrom (0.00s)\n=== RUN   TestGenerateSelectFrom_Selection\n--- PASS: TestGenerateSelectFrom_Selection (0.00s)\n=== RUN   TestGenerateSelectFrom_CaseWhenThen\n--- PASS: TestGenerateSelectFrom_CaseWhenThen (0.00s)\n=== RUN   TestGenerateSelectFrom_CaseDefaultValueSub\n--- PASS: TestGenerateSelectFrom_CaseDefaultValueSub (0.00s)\n=== RUN   TestGenerateSelectFrom_SqlFunc\n--- PASS: TestGenerateSelectFrom_SqlFunc (0.00s)\n=== RUN   TestSqlLikeAndBlankDatatype\n--- PASS: TestSqlLikeAndBlankDatatype (0.00s)\n=== RUN   TestSqlLikeWithOperand\n--- PASS: TestSqlLikeWithOperand (0.00s)\n=== RUN   TestBetweenWithOperand\n--- PASS: TestBetweenWithOperand (0.00s)\n=== RUN   TestCompositeWithoutOperand\n--- PASS: TestCompositeWithoutOperand (0.00s)\n=== RUN   TestGenerateOrderBy\n--- PASS: TestGenerateOrderBy (0.00s)\n=== RUN   TestGenerateOrderBy_WithSort\n--- PASS: TestGenerateOrderBy_WithSort (0.00s)\n=== RUN   TestGenerateGroupBy\n--- PASS: TestGenerateGroupBy (0.00s)\n=== RUN   TestGenerateJoin_JOIN\n--- PASS: TestGenerateJoin_JOIN (0.00s)\n=== RUN   TestGenerateJoin_INNER_JOIN\n--- PASS: TestGenerateJoin_INNER_JOIN (0.00s)\n=== RUN   TestGenerateJoin_LEFT_JOIN\n--- PASS: TestGenerateJoin_LEFT_JOIN (0.00s)\n=== RUN   TestGenerateJoin_RIGHT_JOIN\n--- PASS: TestGenerateJoin_RIGHT_JOIN (0.00s)\n=== RUN   TestGenerateHaving\n--- PASS: TestGenerateHaving (0.00s)\n=== RUN   TestGenerateWhere\n--- PASS: TestGenerateWhere (0.00s)\n=== RUN   TestGenerateConditions\n--- PASS: TestGenerateConditions (0.00s)\n=== RUN   TestGenerateConditions_SubQuery\n--- PASS: TestGenerateConditions_SubQuery (0.00s)\n=== RUN   TestLimit_Static\n--- PASS: TestLimit_Static (0.00s)\n=== RUN   TestLimit_ToParam\n--- PASS: TestLimit_ToParam (0.00s)\n=== RUN   TestOffset_Static\n--- PASS: TestOffset_Static (0.00s)\n=== RUN   TestOffset_ToParam\n--- PASS: TestOffset_ToParam (0.00s)\n=== RUN   TestBuildJsonToSql\n--- PASS: TestBuildJsonToSql (0.00s)\n=== RUN   TestGenerateJsonToSql\n--- PASS: TestGenerateJsonToSql (0.00s)\n=== RUN   TestBuildRawUnion\n--- PASS: TestBuildRawUnion (0.00s)\n=== RUN   TestGenerateUnion\n--- PASS: TestGenerateUnion (0.00s)\n=== RUN   TestGenerateBuild_PreventInjection\n--- PASS: TestGenerateBuild_PreventInjection (0.00s)\n=== RUN   TestGenerate_PreventInjection\n--- PASS: TestGenerate_PreventInjection (0.00s)\n=== RUN   TestGenerateBuildUnion_PreventInjection\n--- PASS: TestGenerateBuildUnion_PreventInjection (0.00s)\n=== RUN   TestGenerateUnion_PreventInjection\n--- PASS: TestGenerateUnion_PreventInjection (0.00s)\n=== RUN   TestIsValidDataType\n--- PASS: TestIsValidDataType (0.00s)\n=== RUN   TestGetValueFromDataType\n--- PASS: TestGetValueFromDataType (0.00s)\n=== RUN   TestCheckArrayType\n--- PASS: TestCheckArrayType (0.00s)\n=== RUN   TestArrayConversionToStringExpression\n--- PASS: TestArrayConversionToStringExpression (0.00s)\n=== RUN   TestExtractValueByDataType\n--- PASS: TestExtractValueByDataType (0.00s)\n=== RUN   TestGetSqlExpression\n--- PASS: TestGetSqlExpression (0.00s)\n=== RUN   TestIsValidOperator\n--- PASS: TestIsValidOperator (0.00s)\n=== RUN   TestGetValueFromOperator\n--- PASS: TestGetValueFromOperator (0.00s)\nPASS\ncoverage: 100.0% of statements\n```\n\n## Benchmarking\n\nSpecs:\n\n- MacBook Pro M1 (2020)\n- 8-Cores (arm64)\n- 8GB of RAM\n\n```go\n\u003e go test -bench=. -benchmem\ngoos: darwin\ngoarch: arm64\npkg: github.com/bonkzero404/gojson2sql\nBenchmarkJson2Sql_BuildRaw-8                               29390             39416 ns/op           29289 B/op        507 allocs/op\nBenchmarkJson2Sql_Generate-8                               17575             67617 ns/op           41164 B/op        607 allocs/op\nBenchmarkJson2Sql_Union_BuildRaw-8                         13789             86378 ns/op           65804 B/op       1016 allocs/op\nBenchmarkJson2Sql_Union_Generate-8                          8659            131424 ns/op           76072 B/op       1143 allocs/op\nBenchmarkJson2Sql_BuildRaw_WithSanitizedSQLi-8              8269            146946 ns/op           49644 B/op        627 allocs/op\nBenchmarkJson2Sql_Generate_WithSanitizedSQLi-8              5640            211519 ns/op           61368 B/op        727 allocs/op\nBenchmarkJson2Sql_Union_BuildRaw_WithSanitizedSQLi-8        4190            282480 ns/op           87426 B/op       1137 allocs/op\nBenchmarkJson2Sql_Union_Generate_WithSanitizedSQLi-8        2959            401434 ns/op           97889 B/op       1263 allocs/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonkzero404%2Fgojson2sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbonkzero404%2Fgojson2sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonkzero404%2Fgojson2sql/lists"}