You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SQL Macros Plugin for Starbase provides SQL query validation and enhancement features to improve code quality and prevent common SQL anti-patterns.
4
+
5
+
## Installation
6
+
7
+
```bash
8
+
npm install @starbase/sql-macros-plugin
9
+
```
10
+
11
+
## Usage
12
+
13
+
Add the SqlMacros plugin to your Starbase configuration:
|`preventSelectStar`| boolean |`false`| When enabled, prevents the use of `SELECT *` in queries to encourage explicit column selection |
30
+
31
+
## Features
32
+
33
+
### Prevent SELECT \*
34
+
35
+
When `preventSelectStar` is enabled, the plugin will raise an error if it encounters a `SELECT *` in your SQL queries. This encourages better practices by requiring explicit column selection.
36
+
37
+
Example of invalid query:
38
+
39
+
```sql
40
+
SELECT*FROM users; // Will raise an error
41
+
```
42
+
43
+
Example of valid query:
44
+
45
+
```sql
46
+
SELECT id, username, email FROM users; // Correct usage
47
+
```
48
+
49
+
### Exclude Columns with `$_exclude`
50
+
51
+
The `$_exclude` macro allows you to select all columns except the specified ones. This is useful when you want to avoid listing all columns explicitly except a few.
52
+
53
+
Example usage:
54
+
55
+
```sql
56
+
SELECT $_exclude(password, secret_key) FROM users;
57
+
```
58
+
59
+
In this example, all columns from the `users` table will be selected except for `password` and `secret_key`.
0 commit comments