ossobv / asterisklint

Asterisk PBX configuration syntax checker
GNU General Public License v3.0
61 stars 12 forks source link

RFE: Alter func_odbc-annotate so it expands the func_odbc.conf files #28

Open wdoekes opened 6 years ago

wdoekes commented 6 years ago

Make two commands: func_odbc-annotate and func_odbc-collapse.

The first one should convert this:

; somefunc is awesome
[SOMEFUNC]
readsql=SELECT id AS col1, 'hardcoded' AS col2 FROM table

into this:

; > ODBC_SOMEFUNC
; >
; > read return values: (1) col1, (2) col2
[SOMEFUNC]
readsql=SELECT id AS col1, 'hardcoded' AS col2
  FROM table

and the second one should convert it back to:

; > ODBC_SOMEFUNC
; >
; > read return values: (1) col1, (2) col2
; somefunc is awesome
[SOMEFUNC]
readsql=SELECT id AS col1, 'hardcoded' AS col2 FROM table

This makes for easier editing of long SQL statements.

We have a partial implementation which right now spits out sql format:

[ACCOUNT_ZIPCODE]
;; ACCOUNT_ZIPCODE returns the zipcode for the account that is placing a call.
prefix=MY
readhandle=my_db
readsql=SELECT zip_code FROM account_account WHERE account_id = '${SQL_ESC(${ARG1})}'

becomes:

-- MY_ACCOUNT_ZIPCODE
-- .
-- FUNCTION TYPE: read
-- COLUMNS:
--  1. zip_code
SELECT zip_code
FROM account_account
WHERE account_id = '${SQL_ESC(${ARG1})}';