我刚开始在一个非常小的Sinatra应用程序中使用Sequel.由于我只有一个数据库表,所以我不需要使用模型.
我想更新记录(如果存在)或插入新记录(如果不存在).我提出了以下解决方案:
rec = $nums.where(:number => n, :type => t)
if $nums.select(1).where(rec.exists)
rec.update(:counter => :counter + 1)
else
$nums.insert(:number => n, :counter => 1, :type => t)
end
Run Code Online (Sandbox Code Playgroud)
哪里$nums是DB[:numbers]数据集.
我相信这种方式不是"更新或插入"行为的最优雅实现.
应该怎么做?
我正在尝试使用clang ++在OS X 10.7下编译VCMI.
我配置项目是CXX=clang++因为Apple的gcc似乎没有识别所需的-std=c++0x标志.
我添加-stdlib=libc++了CXXFLAGS因为没有那个铿锵甚至找不到#include <array>.
目前我有: CXXFLAGS= -std=c++0x -stdlib=libc++ -Wall -Wextra -Wcast-align -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wc++11-extensions
问题是我得到以下错误:
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
clang: warning: argument unused during compilation: '-ggdb'
StdInc.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from StdInc.h:3:
In file included from ./../Global.h:32:
In file included from /usr/bin/../lib/c++/v1/algorithm:594:
In …Run Code Online (Sandbox Code Playgroud)