-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add check and test for non-scalar values in primary key #8
Conversation
ac548f7
to
a525dce
Compare
a525dce
to
d456667
Compare
Codecov Report
@@ Coverage Diff @@
## master #8 +/- ##
============================================
+ Coverage 95.65% 95.83% +0.18%
- Complexity 70 74 +4
============================================
Files 2 2
Lines 138 144 +6
============================================
+ Hits 132 138 +6
Misses 6 6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$oid": "5716054bee6e764c94fa85a6"
Takto sa zapisuje nejaky object v JSONe? Ci to je nejaka Mongo vec?
A "problem" je teda v tom mappingu 'coord' typu table? Ze v tom poli mozu byt len stringy a nie objekty?
Vyzera to dobre, len sa to snazim trochu pochopit od pohladu :)
Je to standardny zapis, akurat je v key dolar. mam tento JSON: {
"_id": {
"\$oid": "5716054bee6e764c94fa85a6"
},
"coord": [
{
"a": 1
},
{
"a": 2
}
]
} Problem nastane, ked si nastavim mapping len cez {
"\$oid": "5716054bee6e764c94fa85a6"
} a nasledne sa nastavi ako PK. Ked na to zavolam json_decode, dostanem: object(stdClass)#1 (1) {
["$oid"]=>
string(24) "5716054bee6e764c94fa85a6"
}
// resp. keby bol assoc param na true:
array(1) {
["$oid"]=>
string(24) "5716054bee6e764c94fa85a6"
} Co nie je validna hodnota pre primarny kluc. Spravne musi byt ten mapping nastaveny |
Zjednodusene povedane, toto je nie validny PK (teraz neriesim ci je to stdClass alebo array): [
["$oid" => "5716054bee6e764c94fa85a6"]
] |
Tento mapping je zly: $config = [
'_id' => [
'type' => 'column',
'mapping' => [
'destination' => 'id',
'primaryKey' => true,
]
],
'coord' => [
'type' => 'table',
'destination' => 'coord',
'tableMapping' => [
'a' => 'a',
]
]
]; Tento uz je ok: $config = [
'_id.$oid' => [
'type' => 'column',
'mapping' => [
'destination' => 'id',
'primaryKey' => true,
]
],
'coord' => [
'type' => 'table',
'destination' => 'coord',
'tableMapping' => [
'a' => 'a',
]
]
]; |
Jasne, uz rozumiem. |
A |
No |
Fixes #7