-
Notifications
You must be signed in to change notification settings - Fork 600
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
Add support for case insensitive dynamic pocos #709
Add support for case insensitive dynamic pocos #709
Conversation
Add unit test to confirm.
1. Try to drop the user first so we can use the "user still connected" failure to bypass setup i.e. assume already setup correctly. This is to allow the developer to stay connected to the database (via SQLPlus or SQL Developer). Modify OracleTestProvider 1. If Oracle setup fails, propagate failure to all tests without retrying for every test in the batch. This makes all tests fail with the same exception. In the case the user is still connected, setup is bypassed. Fix Oracle build scripts 1. Stored procedures don't use any characters to denote a parameter, so they have to be fully qualified e.g. ProcName.paramName to differentiate them from column names (if the same name is used e.g. age). Fix breaking tests: 1. QueryTests.cs had couple of malformed sql statements after string concatenation (missing space). 2. Override all (Oracle)StoredProcTests.cs methods that require an additional RefCursor output parameter. 3. Override all (Oracle)QueryTests.cs paging methods that require '*' to be aliased. 4. OracleQueryTests.cs had a couple of statements ending in a semi-colon, which it didn't appreciate. 5. Fix top 1 query in "QueryMultiple ForSingleResultsSetWithMultiPoco ShouldReturnValidPocoCollection". Also provide version 12c and above syntax. 6. Skip MultiResultSetWithMultiPoco tests since Oracle also does not support it (as with MSAccess and Firebird).
…ds. Oracle doesn't utilize the parameter prefix in this case. Fixes #691 Give OracleDatabaseProvider its own implementation of BuildPageQuery and use "Select null from dual" instead of "Select null" when ORDER BY clause is absent. Alo include version 12c and above syntax in a comment for future reference.
Co-authored-by: Stelio Kontos <[email protected]>
…of "undoing" the pramPrefix modification in OracleDatabaseProvider.
…etaPoco into feature/oracle-support
Co-authored-by: Stelio Kontos <[email protected]>
…etaPoco into feature/oracle-support
@Curlack, looking forward to taking a look at the changes. There is a slight issue with commits from the previous PR being included in the new one, likely due to the hard reset earlier (easily fixed, though). Looking at the commit hashes in this case, it appears that the new commits were done without first rebasing onto upstream's feature/oracle-support branch following the final force-push you did from the Github web UI (notice commit e57bf10 in this PR, which was actually replaced by b36c22b when you did the final force-push in #707). Should be fairly painless to fix, you probably can just c/p the git commands below all at once and call it a day. I added inline comments so you know what's going on, but essentially we're just making a new branch without your new changes, applying only your new commits that we want to it, then replacing your original feature branch with the new one. # Create a new private feature branch ("fix-oracle-quoting") from upstream's "feature/oracle-support" branch;
# this gives you a clean slate based on the upstream branch without any of your new commits
git checkout -b fix-oracle-quoting upstream/feature/oracle-support
# Now we apply your changes for this PR (in order) to this new private feature branch;
# this is effectively the same as what rebasing does, by replaying the commits from another branch
# as if they all occurred in order on a single branch.
git cherry-pick 82f67b8 5cf2dea df1d8b2 0addb74
# In this case, we need to fix up your "feature/oracle-support" private branch which you opened the PR from,
# so just overwrite it with our new feature branch "fix-oracle-quoting"
git branch -f feature/oracle-support fix-oracle-quoting
# Force push to your remote and the PR should be fixed
git push origin feature/oracle-support --force For what it's worth, git can be a bit of a brainf**k between local, remote, origin, upstream, and who is mine and theirs LOL, so don't feel bad. I generally I create a short-lived private feature branch for each PR; it's not necessary, but it does encapsulate that PR's changes separately from the target branch fairly well.
|
Thanks for all the help and patience. I'm busy trying to fix as you indicated, but it seems git doesn't know about branch |
…ited" identifiers. Add support for case insensitive dynamic objects. ExpandoPoco vs ExpandoObject. To be used by OracleOrdinaryDatabaseProvider. Add "UseOrdinaryIdentifiers" flag to IProvider to provide a global means of controlling the activation of case insensitive dynamic objects. Add "ignoreCase" optional parameter to all Database constructors (except the ones taking in a provider) and Poco factory methods. Add "UsingCaseInsensitiveProvider" configuration extension. Switch between OracleDatabaseProvider and OracleOrdinaryDatabaseProvider based on "UseOrdinaryIdentifiers" flag when Resolving Provider.
I've been following this from the sidelines, but looking now at the code changes, I have reservations about what's being added -- seems like a lot of things that shouldn't really be the business of this library. Many databases have case-sensitivity issues, and I think it's up to the user to set up their default mapper to handle it. I don't like adding an |
Also, adding a property to |
I'm on mobile so double check for typos... Make sure you fetch upstream first. Also this repo needs set as upstream remote if it isn't already; check with Run |
Noted. I was expecting this, hence me mentioning the eyebrows earlier. Open to suggestions at this point, but completely agree with you. Of the two extremes, I first went this route then we'll work our way back to the ideal. |
I think I did it! ...,but you'll be the judge when you get a chance. PS: When you do the review, don't review with the aim to approve the PR this time, but rather as a way to show you my changes to better collaborate. Not sure if there is another way to share code that does involve a PR. |
Welp, replying on my phone, clearly haven't learned my lesson... Disregard the accidental PR status change. I'll be at pc in a couple hrs, going to refrain from further participation until then for the sanity of all of you lol. |
@Curlack I may be missing something, but the fact that I've never used Oracle, so there are probably some things specific to that db that I'm unaware of. Reading your comment about delimited vs. ordinary, it sounds similar to how Postgres handles things, which I am familiar with. IMO, it's the job of the user to understand that PP always escapes identifiers and plan accordingly with respect to database design and PetaPoco mapper. For example, since Postgres folds unquoted names to lowercase, it's common to name tables and columns all in lowercase. But since I know that PetaPoco will quote all identifiers, and since POCO class and property names are PascalCase, I always attach a mapper to my I'll also add that an option on the provider to "ignore case" seems vague. For example, queries against a (This is also something that can be solved with current functionality. I defined my columns as So...I don't see anything here that adds relevant functionality to the library, and I would currently vote against merging this PR. If you can explain succinctly what I'm not seeing, I'm open to having my mind changed. |
Agreed.
Couldn't think of a better name, but mentioned in the XML comment that it's whether to use case insensitive dynamic object. This only applies to the property accessors in the dynamic object coming from the
Your comments have been very helpful and actually gave me a better idea. So agreed, no merge. SummaryFrom Oracle's perspective, delimited identifiers are the exception to the rule. My approach was based on this, which led me down the wrong path. From PP's perspective, ordinary identifiers are actually the exception to the rule. For my next trick, I'll be taking this approach. I'm gonna have a look at some of the Postgres tests and core implementation and start reworking these changes. @Ste1io don't even bother reviewing this PR. The changes are too invasive with no real value to the core concept of this library. They also contain breaking changes with no real justification New game plan:
Thanks again for all the help, really appreciate it. |
@Curlack Thanks for your comments. I haven't looked in detail at the Oracle code, but from a high level, I would suggest focusing on getting current tests to pass out of the box. Maybe there's something that needs to be restructured in the tests in order to accommodate Oracle, though I'm pretty sure there was a point at which they all passed. Maybe take a look at NPoco to see how they do things. (NPoco is a well-maintained fork of the project this repo also came from.) If you think there's a need to provide alternative approaches for Oracle, consider whether the better place for that might be a separate library or even just a page in the Wiki with tips and hints. Consider also whether Oracle is more in need of this attention than other databases; I don't see any open issues in the repo relating to these things. |
PetaPoco 对postgres 数据库支持有bug , 当插入数据表, 数据表会带有引号“myTable”, 报错信息: Npgsql.PostgresException:“42P01: 关系 "myTable" 不存在”; 实际上表是存在的,查询没问题, 当执行insert,update , delete ,就会包这样的错误 |
Split Oracle scripts and tests to test usage of "ordinary" and "delimited" identifiers.
Add support for case insensitive dynamic objects.
ExpandoPoco
vsExpandoObject
. To be used byOracleOrdinaryDatabaseProvider
.Add
UseOrdinaryIdentifiers
flag toIProvider
to provide a global means of controlling the activation of case insensitive dynamic objects.Add
ignoreCase
optional parameter to all Database constructors (except the ones taking in a provider) and Poco factory methods.Add
UsingCaseInsensitiveProvider
configuration extension.Switch between
OracleDatabaseProvider
andOracleOrdinaryDatabaseProvider
based onUseOrdinaryIdentifiers
flag when Resolving Provider.