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

feat: select columns #2

Merged
merged 7 commits into from
Nov 28, 2024
Merged

feat: select columns #2

merged 7 commits into from
Nov 28, 2024

Conversation

ymarcon
Copy link
Contributor

@ymarcon ymarcon commented Nov 27, 2024

Columns to select can be specified by providing a list of field names.

Other updates:

  • sort direction is case insensitive
  • added documentation about filter, sort and range query parameters

Copy link

@guilbep guilbep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça ressemble vraiment a du JSON. Pourquoi on utilise pas un parser json ? ou alors j'ai loupé qqch ?

@ymarcon
Copy link
Contributor Author

ymarcon commented Nov 28, 2024

Ça ressemble vraiment a du JSON. Pourquoi on utilise pas un parser json ? ou alors j'ai loupé qqch ?

Oui ce serait bien d'avoir une forme de validation. Note qu'il y a un peu de flexibilité pour pouvoir gérer les jointures. Ce n'est pas encore documenté mais c'est possible de spécifier des critères sur les tables jointes, genre "donne moi les études dont les buildings sont ceci celà". Présentement ça marche mais l'api aurait besoin d'être améliorée je pense.

@ymarcon ymarcon merged commit d71fc2c into main Nov 28, 2024
@guilbep
Copy link

guilbep commented Nov 28, 2024

@ymarcon the lllm generated this jsonSchema :)

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ENAC-IT4R Python SQL Utils",
  "type": "object",
  "properties": {
    "filter": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "$and": {
            "type": "array",
            "items": { "$ref": "#" }
          },
          "$or": {
            "type": "array",
            "items": { "$ref": "#" }
          },
          "$eq": { "type": "string" },
          "$ne": { "type": "string" },
          "$lt": { "type": "number" },
          "$lte": { "type": "number" },
          "$le": { "type": "number" },
          "$gt": { "type": "number" },
          "$gte": { "type": "number" },
          "$ge": { "type": "number" },
          "$ilike": { "type": "string" },
          "$like": { "type": "string" },
          "$contains": {
            "type": "array",
            "items": { "type": "string" }
          },
          "$in": {
            "type": "array",
            "items": { "type": "string" }
          },
          "$nin": {
            "type": "array",
            "items": { "type": "string" }
          },
          "$exists": { "type": "boolean" }
        },
        "additionalProperties": false
      }
    },
    "sort": {
      "type": "array",
      "items": [
        { "type": "string" },
        { "type": "string", "enum": ["ASC", "DESC"], "default": "ASC" }
      ],
      "minItems": 1,
      "maxItems": 2
    },
    "range": {
      "type": "array",
      "items": { "type": "integer" },
      "minItems": 2,
      "maxItems": 2
    }
  },
  "required": ["filter", "sort", "range"],
  "additionalProperties": false
}

@ymarcon
Copy link
Contributor Author

ymarcon commented Nov 28, 2024

Mis à part qu'il faudrait un "additionalProperties": true sur filter, c'est pas mal bon!

@ymarcon
Copy link
Contributor Author

ymarcon commented Nov 28, 2024

See issue #3

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

Successfully merging this pull request may close these issues.

2 participants