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

Searching for Dates in Non Standard Formats MySQL #854

Open
ctilley83 opened this issue Jan 12, 2024 · 1 comment
Open

Searching for Dates in Non Standard Formats MySQL #854

ctilley83 opened this issue Jan 12, 2024 · 1 comment

Comments

@ctilley83
Copy link

NestJS 10.3
Typeorm: 0.3.17
Is it possible to search for dates using mysql's STR_TO_DATE(str,format) function? I have defined a few columns as searchable, and it would be nice to pass in a format so the date format on the frontend can be used. I'm not sure if that's possible through this package or any of the ORMs supported by NestJS.

@Helveg
Copy link
Collaborator

Helveg commented Mar 3, 2024

Hi there! Take a look at the source code here:

const condition: WherePredicateOperator = {
operator: 'ilike',
parameters: [alias, `:${property.column}`],
}
if (['postgres', 'cockroachdb'].includes(queryBuilder.connection.options.type)) {
condition.parameters[0] = `CAST(${condition.parameters[0]} AS text)`
}
qb.orWhere(qb['createWhereConditionExpression'](condition), {
[property.column]: `%${query.search}%`,
})

We seem to apply the ilike operator. Since I don't know the specific MySQL feature you're talking about, maybe you can see how to implement this feature?

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

No branches or pull requests

2 participants