There is no license information available for the latest version (1.0.1) of this package.

Parser of SQL attributes, which offers the ability to add metadata on SQL queries.

1.0.1 2024-05-16 11:54 UTC

This package is auto-updated.

Last update: 2024-05-16 11:55:41 UTC


This repository provides a way to parse SQL attributes, which offers the ability to add metadata on SQL queries.

Table of contents

SQL attributes syntax

This parser will allow you to parse SQL attributes that are attached to any SQL statement or expression into an SQL query. SQL attributes are unofficial ways to add some metadata on SQL statements and expressions in order to apply specific behaviors or automated processes regarding the SQL query the attributes are attached on. In this way, they acts like PHP Attributes.


Attributes are applicable on statements:


They are also applicable on expressions:

FROM `myTable`;

Attributes can own arguments to vary the specific behaviors the processors of those attributes may have:

#[Since(version: 8.0.5, dbms_list: 'mysql,pgsql,oracle')]

The arguments are mandatory to be named, and their values are always interpreted as strings. To allow characters separators like : or , in your values, you must wrap the value of your argument with simple quotes (') or double quotes (").

SQL Attribute definition

The EBNF for the syntax of attributes is:

attribute           = "#[", attribute-name, [ attribute-arguments ], "]";
attribute-name      = uppercase-letter, { letter / digit };
attribute-arguments = "(", { attribute-argument, ",{[ ]}" }, ")";
attribute-argument  = {letter / digit / "_" / "-"}, ":{[ ]}", ["'" / '"'], STRING, ["'" / '"'];
uppercase-letter    = "A" .. "Z";
lowercase-letter    = "a" .. "z";
letter              = [uppercase-letter / lowercase-letter]
digit               = "0" .. "9";


Via composer, you can add the repository in your composer.json by doing:

composer require aareon-france/sql-attributes-parser