StringInterpolationConvertible can't distinguish string literal segments from \(...) clauses containing strings.

Originator:gwendal.roue
Number:rdar://23155201 Date Originated:2015/10/17
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.0 (7A218)
Classification:Serious Bug Reproducible:Always
 
Summary:
StringInterpolationConvertible can't distinguish string literal segments from \(...) clauses containing strings. This limits seriously the usefulness of this protocol.

Steps to Reproduce:
1. Develop a Swift library around SQLite (http://github.com/groue/GRDB.swift).
2. Come across StringInterpolationConvertible.
3. Dream about safe argument injection in SQL queries, as in "SELECT * FROM table WHERE name = \(name)".
4. Drool when you realize that StringInterpolationConvertible could generate the lists of question marks needed by "SELECT * FROM TABLE WHERE id IN \(ids)".
5. (mentally postpone this glossy feature until Swift 2.1, when string literals can be used in interpolated strings)
6. Play with StringInterpolationConvertible, and discover that "foo\(string)" triggers `init<T>(stringInterpolationSegment expr: T)` with two strings. Which one is the SQL query segment, which one is the SQL argument? No one could tell.

Expected Results:
The joy of being able to offer a great API for generating SQL queries with safe argument interpolation.

Actual Results:
The feeling that StringInterpolationConvertible could have been a great protocol, and fell short.

Version:
Xcode 7.0 (7A218)
OSX 10.10.5 (14F27)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!