Fixes incorrect SQLs on generating dummy data.

The number of columns in the SQLs doesn't match the number of rows,
so an error like below occurs:

ERROR 1136 (21S01) at line 50929: Column count doesn't match value count
at row 1

Signed-off-by: Shinya Yamaoka <contact@mail.libmacro.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Shinya Yamaoka 2014-12-07 16:19:04 +09:00 committed by Lukas Fleischer
parent b56dceaa8a
commit d3caf42301

View file

@ -259,7 +259,7 @@ for p in list(seen_pkgs.keys()):
deptype = random.randrange(1, 5) deptype = random.randrange(1, 5)
if deptype == 4: if deptype == 4:
dep += ": for " + random.choice([k for k in seen_pkgs]) dep += ": for " + random.choice([k for k in seen_pkgs])
s = "INSERT INTO PackageDepends VALUES (%d, %d, '%s', NULL);\n" s = "INSERT INTO PackageDepends(PackageID, DepTypeID, DepName) VALUES (%d, %d, '%s');\n"
s = s % (seen_pkgs[p], deptype, dep) s = s % (seen_pkgs[p], deptype, dep)
out.write(s) out.write(s)
@ -267,7 +267,7 @@ for p in list(seen_pkgs.keys()):
for i in range(0, num_deps): for i in range(0, num_deps):
rel = random.choice([k for k in seen_pkgs]) rel = random.choice([k for k in seen_pkgs])
reltype = random.randrange(1, 4) reltype = random.randrange(1, 4)
s = "INSERT INTO PackageRelations VALUES (%d, %d, '%s', NULL);\n" s = "INSERT INTO PackageRelations(PackageID, RelTypeID, RelName) VALUES (%d, %d, '%s');\n"
s = s % (seen_pkgs[p], reltype, rel) s = s % (seen_pkgs[p], reltype, rel)
out.write(s) out.write(s)
@ -279,7 +279,7 @@ for p in list(seen_pkgs.keys()):
p, RANDOM_TLDS[random.randrange(0,len(RANDOM_TLDS))], p, RANDOM_TLDS[random.randrange(0,len(RANDOM_TLDS))],
RANDOM_LOCS[random.randrange(0,len(RANDOM_LOCS))], RANDOM_LOCS[random.randrange(0,len(RANDOM_LOCS))],
src_file, genVersion()) src_file, genVersion())
s = "INSERT INTO PackageSources VALUES (%d, '%s');\n" s = "INSERT INTO PackageSources(PackageID, Source) VALUES (%d, '%s');\n"
s = s % (seen_pkgs[p], src) s = s % (seen_pkgs[p], src)
out.write(s) out.write(s)