我正在尝试使用row_to_json()
PostgreSQL 9.2中添加的函数将查询结果映射到JSON .
我无法找出将连接行表示为嵌套对象的最佳方法(1:1关系)
这是我尝试过的(设置代码:表格,示例数据,然后是查询):
-- some test tables to start out with:
create table role_duties (
id serial primary key,
name varchar
);
create table user_roles (
id serial primary key,
name varchar,
description varchar,
duty_id int, foreign key (duty_id) references role_duties(id)
);
create table users (
id serial primary key,
name varchar,
email varchar,
user_role_id int, foreign key (user_role_id) references user_roles(id)
);
DO $$
DECLARE duty_id int;
DECLARE role_id int;
begin
insert into role_duties (name) values …
Run Code Online (Sandbox Code Playgroud) 这个选项对ld意味着什么?
-lrt
我知道在某种程度上它意味着ld正在寻找具有实时扩展的库,但是在广泛搜索之后,我找不到这是指的确切定义(或哪个库).
使用Bionic(android)libc,android NDK文档详细说明了这个(以及pthreads)已经集成.
我问,因为它似乎是隐式的(即当我调用编译器时,直接调用自定义编译的gdc,我得到一条消息说ld找不到-lrt)
编辑
来自仿生概述
Bionic的C库附带了自己的pthread实现.这与其他历史C库不同:
Run Code Online (Sandbox Code Playgroud)- place it in an external library (-lpthread) - play linker tricks with weak symbols at dynamic link time
对实时功能(aka -lrt)的支持也捆绑在C库中.
问题是collect2将选项-lrt(以及-lpthreads)传递给ld.
dan@devbox:~/projects/gdc_test/jni/src$ $DC gdc_test.d -v -mthumb
Using built-in specs.
Target: arm-linux-androideabi
Configured with: /arm/ndk-git/src/build/../gcc/gcc-4.4.3/configure --prefix=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/arm/ndk-git/build_run/temp-install --with-mpfr=/arm/ndk-git/build_run/temp-install --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --enable-languages=c,d,c++ --enable-lto --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-shared--prefix=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 --enable-initfini-array --disable-nls --prefix=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 --with-sysroot=/arm/ndk-git/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/sysroot --with-binutils-version=2.19 --with-mpfr-version=2.4.1 --with-gmp-version=4.2.4 --with-gcc-version=4.4.3 --with-gdb-version=6.6 --with-arch=armv5te --enable-libstdc__-v3 …
Run Code Online (Sandbox Code Playgroud) 我使用android build-gcc.sh脚本与gcc一起编译了gdc,并在build/core/definitions.mk中包含了一个新的存根来处理D语言文件,作为构建过程的一部分.我知道事情正在编译好,但我的问题是链接:
当我构建项目时,我收到此错误:
ld: crtbegin_so.o: No such file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
对于常规的仅限c的项目也是如此.现在我在构建目录中运行了一个快速查找,发现文件(crtbegin_so.o)确实存在于我编译gcc时指定的sysroot中(或者更确切地说,当build-gcc.sh构建它时).
有什么东西我可以寻找找到这个问题的解决方案?
在本地复制文件并直接链接到它们是一个不错的解决方案吗?
为什么ld(或collect2)会尝试将这些包含在gdc(D语言)链接中?
我在尝试利用Object.defineProperty()
基础对象时遇到了挂起.我想继承该对象的属性,使用Object.create()
,然后在派生对象中定义更多属性(可以从那里继承).我应该注意到我的目标是node.js.
这是一个例子:
var Base = {};
Object.defineProperty(Base, 'prop1', {
enumerable:true,
get:function(){ return 'prop1 value';}
});
Object.defineProperty(Base, 'prop2', {
enumerable:true,
value : 'prop 2 value'
});
Object.defineProperty(Base, 'create', {
value:function(){
return Object.create(Base);
}
});
console.log(Base);
var derived = Base.create();
Object.defineProperty(derived, 'prop3', {
enumerable:true,
value:'prop 3 value'
});
console.log(derived);
Run Code Online (Sandbox Code Playgroud)
其中输出如下:
{ prop1: [Getter], prop2: 'prop 2 value' }
{ prop3: 'prop 3 value' }
Run Code Online (Sandbox Code Playgroud)
我认为console.log()会枚举继承的属性,以及prop3
我在派生对象上定义的属性.它似乎没有查找以这种方式定义的属性的原型层次结构.那是对的吗?
我看着覆盖toString()
我的对象的方法,但似乎console.log()不会调用它.
编辑:
这有什么不对?
res.render('/somepage', {user:req.session.user})
它导致
Converting circular structure to JSONerrors,(导致会话元素具有循环用户引用.)
exports.home = function (req, res) {
var entityFactory = new require('../lib/entity-factory.js').EntityFactory();
entityFactory.get_job_task_lists({
callback : function (err, job_task_lists) {
res.render('home.jade', {
locals:{
title: 'Logged in.',
user:req.session.user, // does not work
job_task_lists:job_task_lists || []
}
});
}
});
};
我添加了一些登录 node_modules/express/node_modules/connect/lib/middleware/session/memory.js
MemoryStore.prototype.set = function(sid, sess, fn){ var self = this; process.nextTick(function(){ console.log(sess); //this is giving the output listed self.sessions[sid] = JSON.stringify(sess); ...
就结构而言,这就是我期望会话的样子:
{ lastAccess: 1330979534026, cookie: { path: '/', httpOnly: true, …
NHibernate中是否有可用的工具,或者可能是实用工具方法,这可以帮助我确定哪个映射正在抛出"字典中没有给定的密钥"?
我知道我必须有一个糟糕的映射,但我有数百个域对象.如何更快地找到错误来源?
来自NHibernate 2.1.2GA来源:
private PersistentClass GetPersistentClass(string className)
{
PersistentClass pc = configuration.classes[className]; // <- "The given key was not present in the dictionary"
if (pc == null)
{
throw new MappingException("persistent class not known: " + className);
}
return pc;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,className是System.Int32.
好的,所以我有一个标记的int字段<many-to-one>
而不是<property>
.我最终挖掘了NH的源代码并进行调试以达到这一点.
我有一个简单的ATL ActiveX控件,用C++实现.
如果我将控件嵌入到网页中,例如:
<object id="api"
classid="CLSID:<guid here>"
height=400
width=800></object>
Run Code Online (Sandbox Code Playgroud)
我知道m_hWnd
如果我m_bWindowOnly = true;
在我的coclass构造函数中设置,我可以从控件中获取HWND .这没问题.
如果我尝试从Javascript实例化此ActiveX控件,过程如下所示:
var object = new ActiveXObject("registeredControlString");
Run Code Online (Sandbox Code Playgroud)
但我没有获得HWND,我不确定如何将其插入DOM中.
我的问题:
在什么情况下我会得到一个可以从控件中引用的HWND?
我有这个VB.net代码片段,我试图弄清楚它为什么是合法的:
Class Program
Public Shared Sub Main(args As String())
Console.WriteLine(New wtf().TestCrazyAssignment())
Console.ReadKey()
End Sub
Class wtf
Public recurse As int32 = 0
Public Function TestCrazyAssignment() As string
TestCrazyAssignment = "this should not be possible."
'BadAllocation = "something" 'compiler error - did not define with Dim
recurse = recurse + 1
Console.WriteLine(TestCrazyAssignment)
If recurse < 10 Then
TestCrazyAssignment()
End If
Return "umm.... ok."
End Function
End Class
End Class
Run Code Online (Sandbox Code Playgroud)
输出:
this should not be possible.
this should not be possible.
this …
Run Code Online (Sandbox Code Playgroud) android-ndk ×2
c++ ×2
gdc ×2
node.js ×2
atl ×1
bionic ×1
c ×1
express ×1
function ×1
gcc ×1
inheritance ×1
javascript ×1
json ×1
nhibernate ×1
postgresql ×1
syntax ×1
vb.net ×1
visual-c++ ×1
win32ole ×1