question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Request for help] Query arguments validation

See original GitHub issue

l2db 1.10.2.

Use case: yesterday I found a subtle bug in own code caused by inserting a record with local time instead of utc.

As a proof we do not do this mistake again I want to add an assertion on L2db level that checks all queries and logs (or throws) if there’s non-utc datetime argument.

In other words, I want to be able to catch things like this:

            await db.Samples.InsertAsync(() => new Sample()
            {
                Id = id,
                CreatedDate = DateTime.Now,        // Bug here 
                DeletedDate = DateTime.UtcNow,
                Description = "..."
            });

I’ve tried

   db.MappingSchema.SetConverter<DateTime, DateTime>(dt => FailIfLocalTime(dt));

but the converter is called only for values from db and is not called for query arguments.

Can you suggest any api that will work for my scenario?

Environment details

linq2db version: 1.10.2 Database Server: MS SQL 2017 Database Provider: Syetem.Data.Sql Operating system: Windows 10 Framework version: .NET Framework 4.7.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sdanylivcommented, Sep 5, 2018

@ig-sinicyn, as i know name is not used here.

1reaction
MaceWinducommented, Sep 5, 2018
MappingSchema.SetConverter<DateTime,DataParameter>(...)

doesn’t work too?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should I validate all query params GET request
Ideally you should validate ALL parameters you need and use only the validated data. You can validate it in controller ...
Read more >
REST API: Validating request params in GET request?
If you have query string param secondaryId on a GET endpoint of a REST API which searches a resource by that secondaryId ,...
Read more >
Spring Boot REST API Validate Query Parameters Examples
Guide and code examples to validate query parameters (request parameters) with Spring Boot and Jakarta Bean validation.
Read more >
Query Parameters and String Validations - FastAPI
FastAPI allows you to declare additional information and validation for your parameters. Let's take this application as example: Python 3.10+ Python 3.6+.
Read more >
Validation on the query parameter · Issue #694 · graphql- ...
I would like to know what is the best place to put validation to the input parameter for the query for example {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found