Giter Site home page Giter Site logo

Comments (8)

Giorgi avatar Giorgi commented on May 19, 2024

Do all the DB Providers that this library supports contain all that information? I can't find it for SqlException. Haven't checked others

from entityframework.exceptions.

STeeL835 avatar STeeL835 commented on May 19, 2024

I can't find it for SqlException.

Right, SqlException doesn't have such properties, but it has needed values in a message:

Cannot insert duplicate key row in object 'dbo.MyTable' with unique index 'UQ_MyTable_ColumnNameOrElse'. The duplicate key value is (duplicatevalue).
The statement has been terminated.

This package could try to extract these values from a message (or elsewhere) and just have corresponding properties nullable if not all providers have them in an exception.

Another option would be to store that info in a Data property (no key = no value provided by the exception) and TryGet.. methods, but this is less favorable option.

from entityframework.exceptions.

Giorgi avatar Giorgi commented on May 19, 2024

@STeeL835 Message is not reliable because it is different based on the language of the database server.

from entityframework.exceptions.

STeeL835 avatar STeeL835 commented on May 19, 2024

@Giorgi You're right.. Well, it could be a "preview" feature, that doesn't guarantee the values (nullable properties still fit) - at least something.

Maybe SqlServerExceptionProcessorStateManager could have a configurable option to modify parsing template if server's language id isn't 1033? We can't check it from exception programmatically - that would need to be checked by users, but we can still check if template fits the actual exception message and log a warning (like "Exception details could not be parsed from a message. If current locale isn't English, template can be modified there.")

from entityframework.exceptions.

Giorgi avatar Giorgi commented on May 19, 2024

Given that it won't work in all cases even for SqlServer, the value added by those properties will be very low while the number of cases it won't work will be very high.

In my opinion parsing of error messages generated by different databases in different languages should be a separate project and not part of this library.

from entityframework.exceptions.

STeeL835 avatar STeeL835 commented on May 19, 2024

Still don't understand, why not. People with providers that support these properties will be happy, people with providers like SqlServer will be able to use a workaround easily (assuming that if you know which DB you're working with, you know its language), and people with none of the options won't lose anything. This lib shouldn't parse all languages of course, but at least could give a tool for it (or an interface for other tools), since it already does the work of intercepting DbUpdateExceptions.

from entityframework.exceptions.

Giorgi avatar Giorgi commented on May 19, 2024

@STeeL835 Which database providers report the constraints/tables that caused the error?

from entityframework.exceptions.

STeeL835 avatar STeeL835 commented on May 19, 2024

@STeeL835 Which database providers report the constraints/tables that caused the error?

For example NpgSql, like in the OP's example. Don't know about the others, though

from entityframework.exceptions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.