Polyglot SQL API Documentation - v0.1.0
    Preparing search index...

    Function validateWithSchema

    • Validate SQL against a database schema.

      Parameters

      • sql: string

        The SQL string to validate

      • schema: Schema

        The database schema definition

      • dialect: string = 'generic'

        The dialect to use for parsing

      • options: SchemaValidationOptions = {}

        Validation options

      Returns ValidationResult

      Validation result with schema-related errors

      const schema: Schema = {
      tables: [{
      name: 'users',
      columns: [
      { name: 'id', type: 'integer', primaryKey: true },
      { name: 'name', type: 'varchar' },
      { name: 'email', type: 'varchar' },
      ],
      }],
      };

      const result = validateWithSchema(
      'SELECT id, name, unknown_col FROM users',
      schema,
      'postgresql'
      );
      // result.errors will contain an error for unknown_col