Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add sql.now(), sql.lower() and sql.upper() functions #5044

Merged
merged 2 commits into from
Dec 23, 2023

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented Dec 23, 2023

sql.now()

When you want to define a default value for a datetime column, you can use the sql.now() function. It resolves to current_timestamp SQL function, and accepts a length parameter.

@Property({ default: sql.now() })
createdAt: Date & Opt;

sql.lower() and sql.upper()

To convert a key to lowercase or uppercase, you can use the sql.lower() and sql.upper() functions

const books = await orm.em.find(Book, {
  [sql.upper('title')]: 'TITLE',
});

@B4nan B4nan force-pushed the sql-functions branch 4 times, most recently from c2f5f11 to e674813 Compare December 23, 2023 13:45
Copy link

codecov bot commented Dec 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f239119) 99.67% compared to head (210742a) 99.68%.
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5044   +/-   ##
=======================================
  Coverage   99.67%   99.68%           
=======================================
  Files         221      221           
  Lines       16317    16362   +45     
  Branches     3926     3939   +13     
=======================================
+ Hits        16264    16310   +46     
+ Misses         53       52    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

### `sql.now()`

When you want to define a default value for a datetime column, you can use the `sql.now()` function. It resolves to `current_timestamp` SQL function, and accepts a `length` parameter.

```ts
@Property({ default: sql.now() })
createdAt: Date & Opt;
```

### `sql.lower()` and `sql.upper()`

To convert a key to lowercase or uppercase, you can use the `sql.lower()` and `sql.upper()` functions

```ts
const books = await orm.em.find(Book, {
  [sql.upper('title')]: 'TITLE',
});
```
### `sql.now()`

When you want to define a default value for a datetime column, you can use the `sql.now()` function. It resolves to `current_timestamp` SQL function, and accepts a `length` parameter.

```ts
@Property({ default: sql.now() })
createdAt: Date & Opt;
```

### `sql.lower()` and `sql.upper()`

To convert a key to lowercase or uppercase, you can use the `sql.lower()` and `sql.upper()` functions

```ts
const books = await orm.em.find(Book, {
  [sql.upper('title')]: 'TITLE',
});
```
@B4nan B4nan merged commit 016fe63 into master Dec 23, 2023
11 checks passed
@B4nan B4nan deleted the sql-functions branch December 23, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant