Aion-Query

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

quote 123       # => 123
quote "123"     # => '123'
quote(0+"123")  # => 123
quote(123 . "") # => '123'
quote 123.0       # => 123.0
quote(0.0+"126")  # => 126
quote("127"+0.0)  # => 127
quote("128"-0.0)  # => 128
quote("129"+1.e-100)  # => 129.0

# use for insert formula: SELECT :x as summ ⇒ x => \"xyz + 123"
quote \"without quote"  # => without quote

# use in: WHERE id in (:x)
quote [1,2,"5"] # => 1, 2, '5'

# use in: INSERT INTO author VALUES :x
quote [[1, 2], [3, "4"]]  # => (1, 2), (3, '4')

# use in multiupdate: UPDATE author SET name=CASE id :x ELSE null END
quote \[2=>'Pushkin A.', 1=>'Pushkin A.S.']  # => WHEN 2 THEN 'Pushkin A.' WHEN 1 THEN 'Pushkin A.S.'

lib/Aion/Query.md  view on Meta::CPAN

quote 123       # => 123
quote "123"     # => '123'
quote(0+"123")  # => 123
quote(123 . "") # => '123'
quote 123.0       # => 123.0
quote(0.0+"126")  # => 126
quote("127"+0.0)  # => 127
quote("128"-0.0)  # => 128
quote("129"+1.e-100)  # => 129.0

# use for insert formula: SELECT :x as summ ⇒ x => \"xyz + 123"
quote \"without quote"  # => without quote

# use in: WHERE id in (:x)
quote [1,2,"5"] # => 1, 2, '5'

# use in: INSERT INTO author VALUES :x
quote [[1, 2], [3, "4"]]  # => (1, 2), (3, '4')

# use in multiupdate: UPDATE author SET name=CASE id :x ELSE null END
quote \[2=>'Pushkin A.', 1=>'Pushkin A.S.']  # => WHEN 2 THEN 'Pushkin A.' WHEN 1 THEN 'Pushkin A.S.'

lib/Aion/Query.pm  view on Meta::CPAN

	quote 123       # => 123
	quote "123"     # => '123'
	quote(0+"123")  # => 123
	quote(123 . "") # => '123'
	quote 123.0       # => 123.0
	quote(0.0+"126")  # => 126
	quote("127"+0.0)  # => 127
	quote("128"-0.0)  # => 128
	quote("129"+1.e-100)  # => 129.0
	
	# use for insert formula: SELECT :x as summ ⇒ x => \"xyz + 123"
	quote \"without quote"  # => without quote
	
	# use in: WHERE id in (:x)
	quote [1,2,"5"] # => 1, 2, '5'
	
	# use in: INSERT INTO author VALUES :x
	quote [[1, 2], [3, "4"]]  # => (1, 2), (3, '4')
	
	# use in multiupdate: UPDATE author SET name=CASE id :x ELSE null END
	quote \[2=>'Pushkin A.', 1=>'Pushkin A.S.']  # => WHEN 2 THEN 'Pushkin A.' WHEN 1 THEN 'Pushkin A.S.'

t/aion/query.t  view on Meta::CPAN

::is scalar do {quote 123}, "123", 'quote 123       # => 123';
::is scalar do {quote "123"}, "'123'", 'quote "123"     # => \'123\'';
::is scalar do {quote(0+"123")}, "123", 'quote(0+"123")  # => 123';
::is scalar do {quote(123 . "")}, "'123'", 'quote(123 . "") # => \'123\'';
::is scalar do {quote 123.0}, "123.0", 'quote 123.0       # => 123.0';
::is scalar do {quote(0.0+"126")}, "126", 'quote(0.0+"126")  # => 126';
::is scalar do {quote("127"+0.0)}, "127", 'quote("127"+0.0)  # => 127';
::is scalar do {quote("128"-0.0)}, "128", 'quote("128"-0.0)  # => 128';
::is scalar do {quote("129"+1.e-100)}, "129.0", 'quote("129"+1.e-100)  # => 129.0';

# use for insert formula: SELECT :x as summ ⇒ x => \"xyz + 123"
::is scalar do {quote \"without quote"}, "without quote", 'quote \"without quote"  # => without quote';

# use in: WHERE id in (:x)
::is scalar do {quote [1,2,"5"]}, "1, 2, '5'", 'quote [1,2,"5"] # => 1, 2, \'5\'';

# use in: INSERT INTO author VALUES :x
::is scalar do {quote [[1, 2], [3, "4"]]}, "(1, 2), (3, '4')", 'quote [[1, 2], [3, "4"]]  # => (1, 2), (3, \'4\')';

# use in multiupdate: UPDATE author SET name=CASE id :x ELSE null END
::is scalar do {quote \[2=>'Pushkin A.', 1=>'Pushkin A.S.']}, "WHEN 2 THEN 'Pushkin A.' WHEN 1 THEN 'Pushkin A.S.'", 'quote \[2=>\'Pushkin A.\', 1=>\'Pushkin A.S.\']  # => WHEN 2 THEN \'Pushkin A.\' WHEN 1 THEN \'Pushkin A.S.\'';



( run in 0.518 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )