nette/database — pull request #3 by hrach (2014-04-23 22:28:43+00:00)
Title: Conventions

**TL;DR**: The aim of this pull request is to separate functionality of IReflection to own classes.

---------------
It's done without serious BC break, BC breaks are introduced only in internal API.

- Reflection is splitted to two parts:
- **DatabaseReflection** - this is class, which reads database structure and stores it in cache. It's API is mostly similar to old IReflection, however, the behavior is different, there is no logic for searching keys for Selection & SqlBuilder
- **Conventions** - separates the logic for autojoining tables into own classes called conventions. DiscoveredConventions has dependency on DatabaseReflection. StaticConventions (old ConventionalReflection) is the same, just renamed, class.
- Backward compatibility:
- I did my best to do it backward compatible. If someone was using IReflection to implement own reflection for Selection & SqlBuilder, it will work, because IReflection is child of IConventions, so it passes through typehint, etc.
- Also old classes such DiscoveredReflecton and ConventionalReflection are still present, and are fully functional, they just raise the deprecated warning.

-------------

This pull requests closes:
- https://github.com/nette/nette/issues/1360
- https://github.com/nette/nette/pull/649

---------------

What else is new:
- Conventions do not throw exceptions where no match is found, just return null, now it's possible to make own chain conventions described in https://github.com/nette/nette/pull/649.
- DatabaseReflection has rebuild method, which allows you easily create cache during the deploy. It's also ready do refactor the nasty cache bug: the cache generating is not as callback -> multiple caches are generated.
- At the end I decided not to remove the getConventions(databaseReflection) method from the Context, since I used it in my projects and it seems convenient.
- However, the getConnection() and getDatabaseReflection() methods are deprecated for Selection.
- The brand new API give us great opportunity to rewrite tests not to use database. (Right now we have `*-3.sql` definition for testing different conventions.)