interpolate: don't break backwards compatibility.

db4
John Benediktsson 2015-04-18 20:22:29 -07:00
parent c5ed2c89fe
commit 7e4d1178c3
5 changed files with 21 additions and 21 deletions

View File

@ -206,7 +206,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
SELECT RAISE(ROLLBACK, 'insert on table "${table-name}" violates foreign key constraint "fki_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"')
WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL;
END;
""" interpolate ;
""" interpolate>string ;
: insert-trigger-not-null ( -- string )
"""
@ -217,7 +217,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
WHERE NEW.${table-id} IS NOT NULL
AND (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL;
END;
""" interpolate ;
""" interpolate>string ;
: update-trigger ( -- string )
"""
@ -227,7 +227,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
SELECT RAISE(ROLLBACK, 'update on table "${table-name}" violates foreign key constraint "fku_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"')
WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL;
END;
""" interpolate ;
""" interpolate>string ;
: update-trigger-not-null ( -- string )
"""
@ -238,7 +238,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
WHERE NEW.${table-id} IS NOT NULL
AND (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = NEW.${table-id}) IS NULL;
END;
""" interpolate ;
""" interpolate>string ;
: delete-trigger-restrict ( -- string )
"""
@ -248,7 +248,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
SELECT RAISE(ROLLBACK, 'delete on table "${foreign-table-name}" violates foreign key constraint "fkd_${table-name}_$table-id}_${foreign-table-name}_${foreign-table-id}_id"')
WHERE (SELECT ${foreign-table-id} FROM ${foreign-table-name} WHERE ${foreign-table-id} = OLD.${foreign-table-id}) IS NOT NULL;
END;
""" interpolate ;
""" interpolate>string ;
: delete-trigger-cascade ( -- string )
"""
@ -257,7 +257,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
FOR EACH ROW BEGIN
DELETE from ${table-name} WHERE ${table-id} = OLD.${foreign-table-id};
END;
""" interpolate ;
""" interpolate>string ;
: can-be-null? ( -- ? )
"sql-spec" get modifiers>> [ +not-null+ = ] any? not ;

View File

@ -1,24 +1,24 @@
USING: help.markup help.syntax io math strings ;
IN: interpolate
HELP: interpolate.
HELP: interpolate
{ $values { "str" string } }
{ $description "String interpolation using named variables and/or stack arguments, writing to the " { $link output-stream } "." }
{ $examples
{ $example
"USING: interpolate ;"
"\"Bob\" \"Alice\" \"Hi ${0}, it's ${1}.\" interpolate."
"\"Bob\" \"Alice\" \"Hi ${0}, it's ${1}.\" interpolate"
"Hi Bob, it's Alice."
}
{ $example
"USING: interpolate namespaces ;"
"\"Fred\" \"name\" [ \"Hi ${name}\" interpolate. ] with-variable"
"\"Fred\" \"name\" [ \"Hi ${name}\" interpolate ] with-variable"
"Hi Fred"
}
} ;
HELP: interpolate
HELP: interpolate>string
{ $values { "str" string } { "newstr" string } }
{ $description "String interpolation using named variables and/or stack arguments, captured as a " { $link string } "." } ;
{ interpolate interpolate. } related-words
{ interpolate interpolate>string } related-words

View File

@ -3,25 +3,25 @@
USING: interpolate io.streams.string namespaces tools.test locals ;
IN: interpolate.tests
{ "A B" } [ "A" "B" "${0} ${1}" interpolate ] unit-test
{ "B A" } [ "A" "B" "${1} ${0}" interpolate ] unit-test
{ "C A" } [ "A" "B" "C" "${2} ${0}" interpolate ] unit-test
{ "A B" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
{ "B A" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
{ "C A" } [ "A" "B" "C" "${2} ${0}" interpolate>string ] unit-test
{ "Hello, Jane." } [
"Jane" "name" set
"Hello, ${name}." interpolate
"Hello, ${name}." interpolate>string
] unit-test
{ "Mr. John" } [
"John" "name" set
"Mr." "${0} ${name}" interpolate
"Mr." "${0} ${name}" interpolate>string
] unit-test
{ "Sup Dawg, we heard you liked rims, so we put rims on your rims so you can roll while you roll." } [
"Dawg" "name" set
"rims" "noun" set
"roll" "verb" set
"Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate
"Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate>string
] unit-test
{ "Oops, I accidentally the whole economy..." } [

View File

@ -57,11 +57,11 @@ TUPLE: stack-var n ;
PRIVATE>
MACRO: interpolate. ( str -- )
MACRO: interpolate ( str -- )
[ [ get ] ] interpolate-quot ;
: interpolate ( str -- newstr )
[ interpolate. ] with-string-writer ; inline
: interpolate>string ( str -- newstr )
[ interpolate ] with-string-writer ; inline
: interpolate-locals ( str -- quot )
[ dup search [ [ ] ] [ [ get ] ] ?if ] interpolate-quot ;

View File

@ -332,7 +332,7 @@ ${example-indent} ""
${example-indent} ""
${example-indent}}
"""
interpolate.
interpolate
] with-variable
] with-variable ;