various compiler improvements consolidated from multiple commits

2012-06-28 13:44:33 -0500: 6f2dfa3 - Fix bug when generating insert queries on django < 1.4.
2012-06-20 15:13:39 -0500: 6b9ca0a - Use SCOPE_IDENTITY in INSERT queries to get the inserted id.
2012-02-09 11:21:00 -0600: c2bc6de - Fix bug when inserting with a specific primary key.
2012-02-07 10:46:54 -0600: b1ecdc4 - Fixed bug in regards to bulk inserting.
2012-02-03 15:46:11 -0600: c7ca41d - Make it backwards compatible.
2012-02-03 12:48:13 -0600: 0dd232b - Deal with bulk_insert related changes.