-
Notifications
You must be signed in to change notification settings - Fork 15
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
trying to implement pgsqlencoder #17
Comments
Thanks for the report @gvasilopulos. I reformatted your post to make it more readable. Even so, I'm not sure what the problem is. Can you reduce this to a simple example with only one or two object fields? |
Sorry for the delay I've been closing shop/moving things from shop to house and been pretty busy. They (fields) cannot get used in forms in their current dotted form so I guess some workaround should be used, since $field($model, dotted.attribute) is not accepted, but I guess that is normal. I do not know if you want me to sent you any related files which I used to do the tests (which are not extended at the moment) if you do, please let me know I 'll be happy to provide anything that you consider necessary(db,project,whatever). Still cannot run the tests, Pg test is kind of empty, but cannot run them even for maria, namespaces seem to be messed up with copying tests folder from github and placing it in yii-dev package,tried to fix autoloads but something seems to be missing. Will try to fix that asap. This is what I used to update 2 of the json objects in the json field (comments)
|
The docs say "The dot notation works anywhere Yii accepts an attribute name string, for example" and then shows using it in @gvasilopulos Can you enter this as a separate issue with a simple test case and the evidence of how it fails (errors, logs)? |
to get the unit tests to work i deleted the entire then check that this line
points to an existing directory in @gvasilopulos try like this and if it still fails, push your work to your fork and tell me the steps i need to take to see the errors that you see |
since 2.0.11 is now released, a simple composer update should work. |
My bad, did not use rules for some strange reason I thought a generic rule ['dynamic_column' , 'safe'] |
ok runned the tests for postgresql and been having some strange failures with unique constraints violation, I removed my test db and recreated it just in case, but still unique constraints violation remain |
@gvasilopulos where is your repo so we can try this for ourselves? both issues may be in tests/unit/data/pgsql.sql.
try...
see what happens |
the repo is this https://github.com/gvasilopulos/yii2-dynamic-ar/tree/pgsql-encoder |
I have a feeling that line 264 is wrong, it is in the middle of an insert statement line 197 looks more like it. So I did it like this. But it didn't fix the problem, what I did is I removed the id from the insert statement and let pg decide through serial, if this approach is wrong then I should figure out why it tries to enter id=1 in every row it tries to insert.. |
What file are you referring to? Generally we use explicit ID values so that we get the same data in the tables every time. So long as we don't violate the PK constant, there should be no problem. And if there is, that suggests there's a different problem.
why do you think it does? |
I think first you should get yii's postgresql tests to work. If they all run properly and pass then you have a basis for elaborating the fixture for dynamic active record. Trying to convert the maria stuff might not be the best way. It might be easier to follow the maria tests as a guide, copying those that should work, or writing something that tests the same kind of thing otherwise. |
After a quick look I imagine that all of DAQ's features can be supported by pgsql's jsonb query features with fairly direct translation. |
Hello I runned the pgtests which gave me this yiisoft/yii2#13511 but I do not think this is a reason not to go ahead.
" |
I've made some changes on PgsqlEncoder.php and runned the tests again. In general we are on the right path. Most of the tests fail because postgres wants every json value that we check against the dynamic column to be quoted and strings to be quoted and double quoted. you can check the results in pgencoder.xml on my repo, if you run the failed queries with numerics as '2343.33' and strings as '"lala"' in the right clause of the where comparisons you will see that they will be accepted. Array tests seem to fail regardless. Please do have a look and throw some idea as how to move on. I think Pgencoder is on a good path now. I used jsonb_extract_path on dynamicAttributeExpression function, it seems to be generic enough for us. One question, are queries with LIKE working straightforward in maria? If this is the case I am afraid in pg this is not supported oob. There are ways to achieve that in sql but dunno how this could be implemented in DAQ/DAR |
I'll try to resemble something of a bug report :-) I have modified PgsqlEncoder.php lines 22-33 to use
To elaborate if something is a string it will be returned as "string" (double quoted) everything else returns normal, which means in the test assertions this lines 352-353 will not work
while this lines 361-362 will work:
if you remain in this function you will see that I altered the test to assert 'null' instead of assertNull and boolean to accept 'true' not 1 , this comes from json pg datatype and the test passes like this. array tests all fail , partialy because I havent altered the test on array test but I thing even so , the array tests have another reason to fail, it is on the third paragraph of the above pg json type link. To make a long story short it says jsonb json objects do not keep the order of keys but store them as they see fit for searching. I think this also gets in the way The tests I used is [this](https://github.com/gvasilopulos/yii2-dynamic-ar/blob/pgsql-encoder/tests/unit/DynamicActiveRecordTestPgJson.php useful notes |
If
|
jsonb_extract_path is the same like #> I find that easy to implement but mostly, I try to avoid "operators", in the case we want to extend dar, or outright include in dar more pg json function, what led me to this decision is the containment operator which is ? and practicaly messes things in PDO and needs to be recreated as a custom operator to work.
|
|
news from the front :-) I altered DynamicActiveQuery Known Issues testWriteRead on line 233 of |
On the above Issue, what fails is the first dataset of dataProviderTestMariaArrayEncoding which is [[1]]. line 120 of https://github.com/gvasilopulos/yii2-dynamic-ar/blob/pgsql-encoder/tests/unit/DynamicActiveRecordTestPgJson.php. |
On the "actual" thing , some info on what happens
running this with the current implementation
returns this
now if we do not call dynColSqlMaria (it is altered by nineinchnick to create jsonb_objects) and simply json_encode like this
it returns this and gets inserted in the db. I do not know what side effects there will be since I cannot run the tests I would like some lecturing on that part :-)
this is the info I could gather
The text was updated successfully, but these errors were encountered: