shannah / xataface

Framework for building data-driven web applications in PHP and MySQL
http://xataface.com
GNU General Public License v2.0
138 stars 58 forks source link

Query Caching Bug Fix #98

Open schirner opened 6 years ago

schirner commented 6 years ago

First of all, thanks a lot for providing such a nice structured interface to MySQL web apps. It helped me a lot!

This PR is a suggestion to fix #97.

first commit

Dependency definitions did not get observed. With original call to loadTable the parameters asked for all tables. The returned object is of type Dataface_DB. Then, condition in line 677 fails. Approach, remove extra parameters, and rely on defaults (no DB defined, single table). With this change, dependencies of a View (as defined in fields.ini) are now observed.

second commit

Tables that have grafted fields using a __sql__ do not get their dependencies attributed. Those tables get a dynamic view named dataface__view__<md5 Sum>. Problem is that the reg ex in line 673 of Dataface/DB.php requires a view in the naming convention of dataface__view__<tableName>_<md5 Sum>. This is needed in order to identify the table name, and subsequently to look up the attributes of the table to determine user listed dependencies.

The second commit changes the view name. The change should be transparent, as just new views are created. Old views are deleted on the next clear views (which operates on dataface__view__%)

One disadvantage of this approach is that column length is limited to 64 characters. Given the current naming conventions, the constant part is already 48 characters long. Leaving only 16 characters for user tables names.