[odb-users] Two namespace in one header file cause generation error

Zhao Xiang xiang.zhao at gamegou.com
Tue Aug 23 08:04:48 EDT 2016


Dear odb support:

I've noticed a possible bug in sql generation if there were two namespaces in one file.


I'm using odb 2.4.0 on windows.


My input file is:


#pragma once
#include <stdint.h>
#include <string.h>
#include <unordered_set>


#include <odb/core.hxx>


#pragma db namespace schema("abcd")
namespace abcd
{
#pragma db object
	struct a
	{
#pragma db id
		uint32_t id;
	};
}


#pragma db namespace schema("abcdef")
namespace abcdef
{
#pragma db object
	struct a
	{
#pragma db id
		uint32_t id;
	};


#pragma db object
	struct b
	{
#pragma db id
		uint32_t id;
	};
}





The command I used was: 


..\..\..\..\..\tools\odb-i686-windows\bin\odb -I../../../../../lib/odb/libodb -I../../../../../lib/ -I../../../common/ -I../../../../../lib/protobuf/src -d mysql --generate-query --generate-schema --std c++11 --profile boost/date-time --profile boost/optional %1


The output sql file I got is:


/* This file was generated by ODB, object-relational mapping (ORM)
 * compiler for C++.
 */


DROP TABLE IF EXISTS `abcd`.`b`;


DROP TABLE IF EXISTS `abcd`.`a`;


CREATE TABLE `abcd`.`a` (
  `id` INT UNSIGNED NOT NULL PRIMARY KEY)
 ENGINE=InnoDB;


CREATE TABLE `abcd`.`b` (
  `id` INT UNSIGNED NOT NULL PRIMARY KEY)
 ENGINE=InnoDB;





As you can see, table `abcdef`.`a` is missing from the file, and table `b` appeared in schema `abcd`, which should be in `abcdef`.


Would you please kindly check it out?


Thanks
Zhao Xiang


More information about the odb-users mailing list