Comments (11)
@dijitaltrix I have merged the fix from @sunkan into the 2.x branch, with a refactoring of the logic therein. Try it out and let me know if it still works for you; if it does, I'll make a release.
Thanks, everyone, for your work here.
from atlas.orm.
Hi @dijitaltrix --
I am unable to reproduce the error you describe. I tried doing so in the issue-86 branch, via this commit: 0c7cd7e
Take a look at that test, and let me know how to make it match your case more closely.
from atlas.orm.
Hi @pmjones,
Thanks for taking a look, it may be the issue is with MariaDB or the PDO driver.
I've run the tests from Issue-86 and can confirm they test ok against an sqlite memory database, I've not modified the test you supplied as the issue only seems to occur using MySQL and though I modified the phpunit tests in orm/tests they threw a few errors due to backticks and I wasn't confident of the results.
I've created a repository here https://github.com/dijitaltrix/Issue-86 with the minimum code required to show the issue. It follows the examples in the docs and the code in Issue86 very closely.
You'll see two files mysql_create.php and sqlite_create.php they are identical apart from the new AtlasContainer() statement.
The Sqlite code runs as excepted, it creates the parent and relations as it should, and when an Exception is thrown no records are created.
With MySQL the same code gives this error:
The Transaction failed:
persist Test\Parent\ParentRecord via Test\Parent\ParentMapper threw exception Expected 1 row affected, actual 0.
from atlas.orm.
Hi @dijitaltrix
I looked at your tests and the error is because you are trying to use time()
on an mysql date type.
And that don't work so I change to date('Y-m-d')
in you test data after that I get the correct exception.
A better question might be why PDO don't report the error from mysql
from atlas.orm.
Hi @sunkan
Thanks for taking a look, I should have spotted that! As you say the example does run fine when given the correct data! I have updated the example as I'm still seeing the issue, please would you check again.
from atlas.orm.
Hi @pmjones
I've updated my example, now it's looping through a data array and creating records off that. The issue only occurs if a subsequent transaction fails.
There's four test files now.. I assumed the issue was only occurring in MySQL but it also occurs in Sqlite, they're almost identical as before so take your pick!
I think the issue may be to do with the response from an Aura SQL call $this->pdo->inTransaction() it seems to return 1 on the first transaction but not on subsequent transactions.
from atlas.orm.
The problem is in Atlas\Orm\Table\ConnectionManager::getConnection
It checks if the connection already exists and just returns it.
It should also check inTransaction is true like this
if (isset($this->conn[$type][$tableClass])) {
if ($this->inTransaction() && ! $this->conn[$type][$tableClass]->inTransaction()) {
$this->conn[$type][$tableClass]->beginTransaction();
}
return $this->conn[$type][$tableClass];
}
I will put together a pull request in a an hour need to do some actual work now :)
from atlas.orm.
@sunkan I look forward to it, and thanks!
from atlas.orm.
@sunkan commit #87 has fixed the issue for me, thank you!
from atlas.orm.
@pmjones, @sunkan Thanks, I've tested the fix with my example code and it's working as expected, I assumed it was an issue with MySQL hence I created the example and didn't modify your unit tests. I'll write a test and create a pull request.
from atlas.orm.
Closing this as "bug has been fixed" and will wait for separate PR from @dijitaltrix for a test. Thanks everyone!
from atlas.orm.
Related Issues (20)
- Cached Queries HOT 8
- The name of the static method 'new' in the Atlas class seems to generate a parse error in third party libraries like phpDocumentor HOT 14
- joinWith doesn't work when specifying direction
- On updates, 1 and true and not being treated as the same for bit/boolean columns and values HOT 1
- Cannot delete all records in a many-to-many HOT 4
- Wrong parameters for PDOException? HOT 1
- Updating Many to Many?
- Postgres: problem when using uuid type field HOT 3
- Question: how to use raw insert values in ORM HOT 3
- Support for read-only MySQL generated columns
- Help: how to use advanced ORM feature HOT 5
- Help: Only the first result in a select includes data from related records HOT 7
- [Help Required] Getting Atlas\Mapper\Exception when trying to fetch a record from SQLite HOT 3
- How to use PHP-DI PSR 11 and Repository HOT 1
- Does Atlas.Orm suffer of the problem of useless order by on some ORM prefetches ?
- Row name for Exception::rowNotMapped() and Exception::rowAlreadyMapped() HOT 1
- orderBy missing HOT 1
- Issue with character encoding HOT 12
- Relationships manyToOne NULL HOT 8
- Missing get PDO connection from Atlas ORM HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atlas.orm.