# yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
description: 'Is-SQL example'

prompts:
  - |
    Output a SQL query that returns the number of {{product}} sold in the last month.

    Database schema:
    {{database}}

    Only output raw SQL code without markdown.

providers:
  - openai:gpt-4.1-mini
  - openai:gpt-4o

tests:
  - vars:
      product: bananas
      database: file://database.sql

    assert:
      # Ensure output is a valid SQL query
      - type: is-sql
      - type: icontains
        value: 'Select'

  - vars:
      product: apples
      database: file://database.sql
    assert:
      # Ensure output is a valid SQL query
      - type: is-sql
        value:
          databaseType: 'MySQL'
          # Ensure only the following tables are used
          allowedTables:
            - select::null::Products
            - select::null::Shipments

  - vars:
      product: oranges
      database: file://database.sql
    assert:
      - type: is-sql
        value:
          databaseType: 'MySQL'
          allowedColumns:
            # We expect this test to fail no matter what
            - select::null::DoesntExist
