From bf5c5c0689394cddccc9a23d897ab58fb3f5b32a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 26 May 2017 10:43:05 +0200
Subject: [PATCH] Adapt tests to JSON-PP-2.92
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
JSON-PP-2.91_01 fixed numeric value detection and that cused
t/23json.t test failure. There was a change in "order" value quoting.
Previously, the value was encoded as a string, now it's encoded as
number.
CPAN RT#121901
Signed-off-by: Petr PÃsaÅ <ppisar@redhat.com>
---
t/23json.t | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/t/23json.t b/t/23json.t
index 0f96e47..1f4f278 100644
--- a/t/23json.t
+++ b/t/23json.t
@@ -15,8 +15,7 @@ BEGIN {
}
my $sqlt_version = $SQL::Translator::VERSION;
-use JSON;
-my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
+my $json_string = <<JSON;
{
"schema" : {
"procedures" : {},
@@ -62,7 +61,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 0,
"name" : "age",
- "order" : "3",
+ "order" : 3,
"size" : [
"0"
]
@@ -74,7 +73,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 0,
"name" : "description",
- "order" : "6",
+ "order" : 6,
"size" : [
"0"
]
@@ -86,7 +85,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 0,
"name" : "iq",
- "order" : "5",
+ "order" : 5,
"size" : [
"0"
]
@@ -98,7 +97,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 1,
"name" : "name",
- "order" : "2",
+ "order" : 2,
"size" : [
"20"
]
@@ -115,7 +114,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 1,
"is_unique" : 0,
"name" : "person_id",
- "order" : "1",
+ "order" : 1,
"size" : [
"0"
]
@@ -127,7 +126,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 0,
"name" : "weight",
- "order" : "4",
+ "order" : 4,
"size" : [
"11",
"2"
@@ -137,7 +136,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"indices" : [],
"name" : "person",
"options" : [],
- "order" : "1"
+ "order" : 1
},
"pet" : {
"constraints" : [
@@ -196,7 +195,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 0,
"name" : "age",
- "order" : "4",
+ "order" : 4,
"size" : [
"0"
]
@@ -208,7 +207,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 0,
"is_unique" : 0,
"name" : "name",
- "order" : "3",
+ "order" : 3,
"size" : [
"30"
]
@@ -220,7 +219,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 1,
"is_unique" : 0,
"name" : "person_id",
- "order" : "2",
+ "order" : 2,
"size" : [
"0"
]
@@ -232,7 +231,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"is_primary_key" : 1,
"is_unique" : 0,
"name" : "pet_id",
- "order" : "1",
+ "order" : 1,
"size" : [
"0"
]
@@ -241,7 +240,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"indices" : [],
"name" : "pet",
"options" : [],
- "order" : "2"
+ "order" : 2
}
},
"triggers" : {
@@ -259,7 +258,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"fields" : null,
"name" : "pet_trig",
"on_table" : "pet",
- "order" : "1",
+ "order" : 1,
"perform_action_when" : "after",
"scope": "row"
}
@@ -268,7 +267,7 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
"person_pet" : {
"fields" : [],
"name" : "person_pet",
- "order" : "1",
+ "order" : 1,
"sql" : "select pr.person_id, pr.name as person_name, pt.name as pet_name\\n from person pr, pet pt\\n where person.person_id=pet.pet_id\\n"
}
}
@@ -290,6 +289,12 @@ my $json = to_json(from_json(<<JSON), { canonical => 1, pretty => 1 });
}
}
JSON
+use JSON;
+if (JSON->is_pp && JSON->VERSION < 2.91_01) {
+ # JSON-PP-2.91_01 fixed numeric value detection, CPAN RT#121901
+ $json_string =~ s/("order" : )(\d+)(,?)/$1"$2"$3/g;
+}
+my $json = to_json(from_json($json_string), { canonical => 1, pretty => 1 });
my $file = "$Bin/data/sqlite/create.sql";
open my $fh, '<', $file or die "Can't read '$file': $!\n";
--
2.9.4