Skip to content
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

Codegen breaking models #107

Closed
StevenWarren opened this issue Jan 31, 2013 · 10 comments
Closed

Codegen breaking models #107

StevenWarren opened this issue Jan 31, 2013 · 10 comments
Labels
Milestone

Comments

@StevenWarren
Copy link

Cloned the framework repository locally and and setup the test database in MySql. After running codegen I am getting the following error:
Parse error: syntax error, unexpected ')' in C:\wamp\www\framework\includes\model\generated\PersonGen.class.php on line 194

It appears that there may be an error in the codegen templates. The generated code looks like:

// Use QuerySingle to Perform the Query
$objToReturn = Person::QuerySingle(
QQ::AndCondition(
QQ::Equal(QQN::Person()->Id, $intId),
),
$objOptionalClauses
);

I've looked through the logs and cannot see any changes that would ave affected this. Is it possible that the logs from SVN did not transfer into GIT completely?

@olegabr
Copy link
Member

olegabr commented Jan 31, 2013

have you cloned master or another branch?
what page did you load to reproduce this error?
what kind of system do you have? win32/64, linux32/64, osx32/64?

@StevenWarren
Copy link
Author

Environment:
Win7 64 bit
Wamp:
PHP: 5.3.1
MySql: 5.5.2
Apache: 2.1.21

I found the issue. Appears to be a file encoding issue since we moved to GitHub's repository. The issue is with the GO_BACK function in QCodeGenBase. The class_load_and_count_methods.tpl.php calls it on line 39 passing an integer of value 2 to remove the last comma. This works fine on all my existing codebases, however on the clone I made from master on GitHub it fails. I used my debugger to look at the code and here is what the output looks like before GO_BACK does its string manipulation https://www.dropbox.com/s/lolavo8uz3g5w1n/before.png and then after https://www.dropbox.com/s/8u6zpv4706c0tqp/after.png . It appears that we have a windows versus Linux EOL issue. Windows carriage return is \r\n while it is \n in Unix. Therefore in Windows the comma is the third character not the second.

@StevenWarren
Copy link
Author

Example of the issue comparing index_load_single.tpl.php https://www.dropbox.com/s/v9nmn2x3zkmbeny/diff_index_load_single.tpl.php.png.

Are any others experiencing this when developing on Windows?

@olegabr
Copy link
Member

olegabr commented Feb 1, 2013

I have not tried qcubed on a windows machine. I'll do that and report results here.

@vaibhav-kaushal
Copy link
Member

This might be strange because I am using the code from master in a small installation and it works well with MySQL (no such errors). BUt I am on Linux (opensuse) / Apache 2.2 / PHP 5.3.18 / MySql 5.5

@StevenWarren
Copy link
Author

The issue seems to be isolated to running QCubed in a Windows environment. I was able to put the same code-base on an Ubuntu VM and everything runs well. I ran a diff on the download I have from before the switch to GitHub and a clone from the master repo and a lot of the files have had the encoding and line endings changed. I don't think this would be an issue accept that the codegen is writing from the templates and the functions like GO_BACK are relying on the output being consistent.

I think from here we need to normalize all the files to use the same EOL characters and encoding. Once this is accomplished I feel we should have a process in place to test the framework on Windows, Mac and Linux environments before it is merged to master.

@vakopian
Copy link
Member

vakopian commented Feb 2, 2013

GO_BACK is an ugly hack I had to put in place when doing automatic conversion from old templates to php templates. There aren't that many of them, we should eliminate them all

@scottux
Copy link
Member

scottux commented Feb 2, 2013

Agreed, we have normalized the directory separators so I don't see why we shouldn't do the same for EOL.

@olegabr
Copy link
Member

olegabr commented Feb 28, 2013

The tutorial on line-endings with git: https://help.github.com/articles/dealing-with-line-endings

olegabr added a commit to olegabr/qcubed that referenced this issue Feb 28, 2013
The instruction was obtained here: https://help.github.com/articles/dealing-with-line-endings
in a "Re-normalizing a repo" part.
@olegabr
Copy link
Member

olegabr commented Feb 28, 2013

fixed in #154

@olegabr olegabr closed this as completed Feb 28, 2013
scottux added a commit that referenced this issue Mar 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants