summary refs log tree commit diff stats
path: root/tests/stdlib/somesql.sql
blob: 74afcbab0358a2f120a687b6c637c79fc9f709d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
create table anon40(
  anon41 anon42 primary key default anon43(),
  anon44 text unique not null,
  anon45 text unique not null,
  anon46 text not null,
  anon47 text not null,
  anon48 text default null,
  anon49 text default null,
  anon50 text default null,
  anon51 text default null,
  anon52 text default null,
  anon53 text default null,
  anon54 text default null,
  anon55 text default null,
  anon56 text default null,
  anon57 text default null,
  anon58 text default null,
  anon59 text default null,
  anon60 text default null,
  anon61 text default null,
  anon62 varchar(30) default null,
  anon63 varchar(30) default null);
create table anon64(
  anon41 serial  primary key,
  anon65 varchar(30) not null unique,
  anon46 varchar(30) not null,
  anon66 varchar(30) not null,
  anon47 varchar(30) not null,
  anon67 text not null,
  anon55 varchar(30) not null unique,
  anon68 varchar(30) default 'o',
  anon69 boolean default true,
  anon70 int not null  references anon40(anon41));
create table anon71(
  anon72 varchar(30) not null  primary key,
  anon73 varchar(30) not null unique,
  anon70 int not null  references anon40(anon41));
create table anon74(
  anon72 varchar(30) not null  primary key,
  anon73 varchar(30) not null unique,
  anon75 varchar(30) not null,
  anon70 int not null references anon40(anon41),
  foreign key(anon75) references anon71(anon72));
create table anon76(
  anon41 serial  primary key,
  anon72 varchar(30) not null unique,
  anon73 varchar(30) not null unique,
  anon77 varchar(30) not null,
  anon70 int not null  references anon40(anon41),
  foreign key(anon77) references anon74(anon72));
create table anon78(
  anon41 serial  primary key,
  anon72 varchar(30) not null unique,
  anon73 varchar(30) not null unique,
  anon79 int not null,
  anon80 varchar(30) default null,
  anon81 int not null,
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41),
  foreign key(anon79) references anon78(anon41),
  foreign key(anon81) references anon76(anon41));
create table anon82(
  anon41 serial  primary key,
  anon72 varchar(30) not null unique,
  anon73 text not null unique,
  anon79 int not null,
  anon80 text default null,
  anon83 varchar(30) not null default 'd',
  anon84 decimal default 0.00,
  anon69 boolean not null default true,
  anon85 decimal default 0.00,
  anon86 decimal default 0.00,
  anon87 decimal default 0.00,
  anon70 int not null  references anon40(anon41),
  foreign key(anon79) references anon78(anon41));
create table anon88(
  anon41 serial  primary key,
  anon72 varchar(30) not null unique,
  anon80 text default '',
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41));
create table anon89(
  anon90 int not null  primary key,
  anon91 anon92 default 0.00,
  anon93 varchar(30),
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41),
  foreign key(anon90) references anon82(anon41));
create table anon94(
  anon41 serial  primary key,
  anon73 text unique not null,
  anon80 text default null,
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41));
create table anon95(
  anon41 serial  primary key,
  anon73 text unique not null,
  anon96 int not null  references anon94(anon41),
  anon80 text default null,
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41));
create table anon97(
  anon41 serial  primary key,
  anon73 text unique not null,
  anon98 int not null  references anon95(anon41),
  anon80 text default null,
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41));
create table anon99(
  anon41 serial  primary key,
  anon73 varchar(30) unique not null,
  anon100 varchar(30) default null,
  anon101 anon102 default 0,
  anon103 varchar(30) default 'g',
  anon104 int not null,
  anon105 decimal not null default 1,
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41));
create table anon106(
  anon107 varchar(30) default 'g',
  anon108 int  references anon99(anon41) not null,
  anon109 decimal default 1,
  anon110 int  references anon99(anon41) not null,
  anon70 int not null  references anon40(anon41));
create table anon111(
  anon41 serial  primary key,
  anon112 text unique not null,
  anon73 text unique not null,
  anon113 anon102  references anon97(anon41) not null,
  anon114 varchar(30) not null,
  anon115 int not null  references anon88(anon41),
  anon116 int not null  references anon82(anon41),
  anon117 int not null  references anon82(anon41),
  anon118 int not null  references anon82(anon41),
  anon119 int not null  references anon82(anon41),
  anon120 int not null  references anon82(anon41),
  anon121 int not null  references anon82(anon41),
  anon122 int  references anon99(anon41) not null,
  anon123 decimal default 0.00,
  anon124 decimal default 0.00,
  anon69 boolean default true,
  anon70 int not null  references anon40(anon41));
create table anon125(
  anon41 serial  primary key,
  anon126 int  references anon111(anon41) not null,
  anon80 text not null,
  anon127 varchar(30) not null,
  anon128 decimal default 0.00,
  anon129 decimal default 0,
  anon130 decimal default 0,
  anon131 decimal default 0,
  anon132 decimal default 0,
  anon133 decimal default 0.00,
  anon134 decimal default 0.00,
  anon135 decimal default 0.00,
  anon70 int not null  references anon40(anon41),  constraint anon136 check anon137(anon126, anon127, anon129));
create table anon138(
  anon41 serial  primary key,
  anon126 int  references anon111(anon41) not null,
  anon80 text not null,
  anon127 varchar(30) not null,
  anon139 date not null,
  anon129 decimal default 0,
  anon130 decimal default 0,
  anon131 decimal default 0,
  anon132 decimal default 0,
  anon70 int not null  references anon40(anon41),  constraint anon136 check anon137(anon127, anon129));
create table anon140(
  anon41 serial  primary key,
  anon141 text unique not null,
  anon46 text default null,
  anon47 text default null,
  anon57 varchar(30) default null,
  anon142 text default null,
  anon51 text default null,
  anon143 varchar(30) default null,
  anon53 text default null,
  anon54 text default null,
  anon55 text default null,
  anon45 text default null,
  anon69 boolean default true,
  anon70 int not null  references anon40(anon41));
create table anon144(
  anon41 serial  primary key,
  anon72 varchar(30) unique not null,
  anon73 varchar(30) unique not null,
  anon80 varchar(30) default null,
  anon69 boolean default true,
  anon70 int not null  references anon40(anon41));
create table anon145(
  anon41 serial  primary key,
  anon72 varchar(30) unique not null,
  anon73 varchar(30) unique not null,
  anon146 int not null,
  anon147 anon92 default 1,
  anon148 anon92 default 9999999,
  anon80 varchar(30) default null,
  anon69 boolean default true,
  anon149 int default 0,
  anon150 int not null,
  anon151 anon92 default 0,
  anon70 int not null  references anon40(anon41),
  foreign key(anon150) references anon82(anon41),
  foreign key(anon146) references anon144(anon41));
create table anon152(
  anon41 serial  primary key,
  anon73 varchar(30) not null unique,
  anon153 varchar(30) not null unique,
  anon80 text default null,
  anon69 boolean not null default true,
  anon70 int not null  references anon40(anon41));
create table anon154(
  anon41 serial  primary key not null,
  anon155 int not null unique,
  date date default anon156 not null,
  anon157 anon102  references anon140(anon41) not null,
  anon158 anon102  references anon64(anon41) not null,
  anon159 decimal default 0 not null,
  anon160 decimal default 0 not null,
  anon161 decimal default 0 not null,
  anon162 decimal default 0 not null,
  anon163 decimal default 0 not null,
  anon164 decimal default 0 not null,
  anon165 decimal default 0.00,
  anon166 decimal default 0 not null,
  anon167 decimal default 0.00,
  anon168 decimal default 0 not null,
  anon169 boolean default false,
  anon170 varchar(30) default 'ca',
  anon171 varchar(30) default 'n',
  anon172 varchar(30) not null default 'd',
  anon173 decimal default 0.00,
  anon174 decimal default 0.00,
  anon175 int,
  anon176 varchar(30) default null,
  anon177 varchar(30) default '',
  anon178 varchar(30) default null,
  anon70 int not null  references anon40(anon41));
create table anon179(
  anon41 serial  primary key not null,
  anon180 anon102  references anon154(anon41) not null,
  anon181 int  references anon125(anon41) not null,
  anon182 int  references anon82(anon41) not null,
  anon122 int  references anon99(anon41) not null,
  anon183 decimal not null,
  anon184 decimal default 0.00,
  anon174 decimal default 0,
  anon160 decimal default 0.00,
  anon185 decimal default 0,
  anon162 decimal default 0.00,
  anon186 decimal default 0,
  anon163 decimal default 0.00,
  anon187 decimal default 0,
  anon164 decimal default 0.00,
  anon188 decimal default 0,
  anon161 decimal default 0.00,
  anon189 decimal default 0.00,
  anon168 decimal default 0.00,
  anon190 decimal not null,
  anon191 decimal default 0,
  anon83 varchar(30) not null default 't',
  anon192 decimal default 0,
  anon193 decimal not null,
  anon194 decimal not null,
  anon70 int not null  references anon40(anon41));
create table anon195(
  anon41 serial not null,
  anon196 int not null,
  anon175 char not null,
  anon90 int not null  references anon82,
  anon165 decimal default 0.00,
  anon70 int not null  references anon40(anon41),  primary key(anon196, anon175));
create table anon197(
  anon41 serial not null,
  anon196 int not null,
  anon175 char not null,
  anon198 int not null,
  anon189 decimal default 0.00,
  anon199 varchar(30) default null,
  anon200 varchar(30) default null,
  anon70 int not null  references anon40(anon41),
  primary key(anon196, anon175),
  foreign key(anon198) references anon145(anon41));
create table anon201(
  anon41 serial  primary key,
  anon202 varchar(30) not null,
  anon203 varchar(30) not null,
  anon204 varchar(30) not null,
  anon205 varchar(30) not null,
  anon206 boolean default null,
  anon70 int not null  references anon40(anon41));
create table anon207(
  anon41 serial  primary key,
  anon208 varchar(30) not null,
  anon209 varchar(30) not null,
  anon204 varchar(30) default null,
  anon70 int not null  references anon40(anon41));
select * from anon207 where anon41 in (1, 2, 3);
                               







                                                              
                                                     





                                              



                                                 





















                                                              

                                  


                                                                      
                   
 
                                                                                     


                                                         
                                   
                                       














                                                                                             



                                                                                 


                                                   



                                                                                      
                                     
                                                         
                                                       
                                                  


                                          


                                                             
                                                                  
                                     
                                                                   
 
                                                         
                                   










                                                                                         

                     

                                               

                                                                             

                                     
 




                                                 


                                                                    
                                                
                                                        
                             
                                                             
                                            






                                                          

                       
                                               


                                      
                                                    







                                                                      
 
                                                   






                                                                        
                                                                            

                                                        
        
                                   
                                                                    


                                                                                  

                                   



                                                                           
                                            
                                       









                                                                     
                                      

                                        
                                                  

                                                                      

                                    



                                           
                                        

                                       



                                                               
                                                      
                                           
                              

                                                                     

                                             
                                                     




















                                                                                                      
 
                                  
                                                                 
 


                                                              
 

                                              
 





                                                                        
 




                                                                  
                
                                             
                                                                        
                                                                
                                                  


                                   
                                                    

                                                          

                                        
                                                               
 

                                                                        
                                                  

                                   
                         



                                                                 



                                                         




                                              
 
                        
                                             

                                                                 
                              
                                 

                           
                          
                                                    
                                                                            
                                      

                                   
                                               
                                                                            
                                      
 
                                
                                                                 


                                                                               
                                                                   
                                             


                                      
from ranger.fsobject import BAD_INFO, File, FileSystemObject
from ranger.shared import SettingsAware
from ranger import log
import ranger.fsobject

def sort_by_basename(path):
	"""returns path.basename (for sorting)"""
	return path.basename

def sort_by_directory(path):
	"""returns 0 if path is a directory, otherwise 1 (for sorting)"""
	return 1 - int( isinstance( path, Directory ) )

class NoDirectoryGiven(Exception):
	pass

class Directory(FileSystemObject, SettingsAware):
	enterable = False
	load_generator = None
	loading = False

	filenames = None
	files = None
	filter = None
	marked_items = None
	pointed_index = None
	pointed_file = None
	scroll_begin = 0
	scroll_offset = 0

	old_show_hidden = None
	old_directories_first = None
	old_reverse = None
	old_sort = None

	sort_dict = {
		'basename': sort_by_basename,
		'size': lambda path: path.size,
		'mtime': lambda path: -(path.stat and path.stat.st_mtime or 1),
		'type': lambda path: path.mimetype,
	}

	def __init__(self, path):
		from os.path import isfile

		if isfile(path):
			raise NoDirectoryGiven()

		FileSystemObject.__init__(self, path)

		self.marked_items = set()

		# to find out if something has changed:
		self.old_show_hidden = self.settings.show_hidden
		self.old_directories_first = self.settings.directories_first
		self.old_sort = self.settings.sort
		self.old_reverse = self.settings.reverse
	
	def mark_item(self, item, val):
		item._mark(val)
		if val:
			if item in self.files:
				self.marked_items.add(item)
		else:
			if item in self.marked_items:
				self.marked_items.remove(item)

	def toggle_mark(self, item):
		self.mark_item(item, not item.marked)

	def toggle_all_marks(self):
		for item in self.files:
			self.toggle_mark(item)
	
	def mark_all(self, val):
		for item in self.files:
			self.mark_item(item, val)

		if not val:
			self.marked_items.clear()
			self._clear_marked_items()
	
	def _gc_marked_items(self):
		for item in self.marked_items.copy():
			if item.path not in self.filenames:
				self.marked_items.remove(item)
	
	def _clear_marked_items(self):
		for item in self.marked_items:
			item._mark(False)
		self.marked_items.clear()

	def get_selection(self):
		"""READ ONLY"""
		self._gc_marked_items()
		if self.marked_items:
			return set(self.marked_items)
		elif self.pointed_file:
			return set([self.pointed_file])
		else:
			return set()
	
	def load_bit_by_bit(self):
		"""
		Returns a generator which load a part of the directory
		in each iteration.
		"""

#		log("generating loader for " + self.path + "(" + str(id(self)) + ")")
		from os.path import join, isdir, basename
		from os import listdir

		self.loading = True
		self.load_if_outdated()
		yield

		if self.exists and self.runnable:
			filenames = []
			for fname in listdir(self.path):
				if not self.settings.show_hidden and fname[0] == '.':
					continue
				if isinstance(self.filter, str) and self.filter in fname:
					continue
				filenames.append(join(self.path, fname))
			self.scroll_offset = 0
			self.filenames = filenames
			self.infostring = ' %d' % len(self.filenames) # update the infostring
			yield

			marked_paths = set(map( \
					lambda obj: obj.path, self.marked_items))
			self._clear_marked_items()

			files = []
			for name in self.filenames:
				if isdir(name):
					try:
						item = self.fm.env.get_directory(name)
					except:
						item = Directory(name)
				else:
					item = File(name)
				item.load_if_outdated()
				files.append(item)
				yield

			self.files = files

			for item in self.files:
				if item.path in marked_paths:
					self.mark_item(item, True)
				else:
					self.mark_item(item, False)

			self.old_directories_first = None
			self.sort()

			if len(self.files) > 0:
				if self.pointed_file is not None:
					self.move_pointer_to_file_path(self.pointed_file)
		else:
			self.filenames = None
			self.files = None
			self.infostring = BAD_INFO

		self.content_loaded = True
		self.loading = False
#		yield
#		yield

	def load_content(self, schedule=False):
		"""
		Loads the contents of the directory. Use this sparingly since
		it takes rather long.
		"""

		self.load_once()

		if schedule is None:
			schedule = self.size > 30

		if self.load_generator is None:
			self.load_generator = self.load_bit_by_bit()

			if schedule and self.fm:
				self.fm.loader.add(self)
			else:
				for _ in self.load_generator:
					pass
				self.load_generator = None

		elif not schedule or not self.fm:
			for _ in self.load_generator:
				pass
			self.load_generator = None


	def sort(self):
		"""Sort the containing files"""
		if self.files is None:
			return

		old_pointed_file = self.pointed_file
		try:
			sort_func = self.sort_dict[self.settings.sort]
		except:
			sort_func = sort_by_basename
		self.files.sort(key = sort_func)

		if self.settings.reverse:
			self.files.reverse()

		if self.settings.directories_first:
			self.files.sort(key = sort_by_directory)

		if self.pointed_index is not None:
			self.move_pointer_to_file_path(old_pointed_file)
		else:
			self.correct_pointer()

		self.old_directories_first = self.settings.directories_first
		self.old_sort = self.settings.sort
		self.old_reverse = self.settings.reverse
	
	def sort_if_outdated(self):
		"""Sort the containing files if they are outdated"""
		if self.old_directories_first != self.settings.directories_first \
				or self.old_sort != self.settings.sort \
				or self.old_reverse != self.settings.reverse:
			self.sort()

	# Notice: fm.env.cf should always point to the current file. If you
	# modify the current directory with this function, make sure
	# to update fm.env.cf aswell.
	def move_pointer(self, relative=0, absolute=None):
		"""Move the index pointer"""
		if self.empty(): return
		i = self.pointed_index
		if isinstance(absolute, int):
			if absolute < 0:
				absolute = len(self.files) + absolute
			i = absolute

		if isinstance(relative, int):
			i += relative

		self.pointed_index = i
		self.correct_pointer()
		return self.pointed_file

	def move_pointer_to_file_path(self, path):
		"""
		Move the index pointer to the index of the file object
		with the given path.
		"""
		if path is None: return
		try: path = path.path
		except AttributeError: pass

		self.load_content_once()
		if self.empty(): return

		i = 0
		for f in self.files:
			if f.path == path:
				self.move_pointer(absolute = i)
				self.correct_pointer()
				return True
			i += 1

		return self.move_pointer(absolute=self.pointed_index)
	
	def search(self, arg, direction = 1):
		"""Search for a regular expression"""
		if self.empty() or arg is None:
			return False
		elif hasattr(arg, 'search'):
			fnc = lambda x: arg.search(x.basename)
		else:
			fnc = lambda x: arg in x.basename

		length = len(self)

		if direction > 0:
			generator = ((self.pointed_index + (x + 1)) % length for x in range(length-1))
		else:
			generator = ((self.pointed_index - (x + 1)) % length for x in range(length-1))

		for i in generator:
			_file = self.files[i]
			if fnc(_file):
				self.pointed_index = i
				self.pointed_file = _file
				return True
		return False

	def correct_pointer(self):
		"""Make sure the pointer is in the valid range"""

		if self.files is None or len(self.files) == 0:
			self.pointed_index = None
			self.pointed_file = None

		else:
			i = self.pointed_index

			if i is None: i = 0
			if i >= len(self.files): i = len(self.files) - 1
			if i < 0: i = 0

			self.pointed_index = i
			self.pointed_file = self[i]

		try:
			if self == self.fm.env.pwd:
				self.fm.env.cf = self.pointed_file
		except:
			pass
		
	def load_content_once(self, *a, **k):
		"""Load the contents of the directory if not done yet"""
		if not self.content_loaded and not self.loading:
			self.load_content(*a, **k)
			return True
		return False

	def load_content_if_outdated(self, *a, **k):
		"""
		Load the contents of the directory if it's
		outdated or not done yet
		"""
		if self.load_content_once(*a, **k): return True

		if self.old_show_hidden != self.settings.show_hidden:
			self.old_show_hidden = self.settings.show_hidden
			self.load_content(*a, **k)
			return True

		import os
		try:
			real_mtime = os.lstat(self.path).st_mtime
		except OSError:
			real_mtime = None
		if self.stat:
			cached_mtime = self.stat.st_mtime
		else:
			cached_mtime = 0

		if real_mtime != cached_mtime:
			self.load_content()
			return True
		return False

	def empty(self):
		"""Is the directory empty?"""
		return self.files is None or len(self.files) == 0

	def __nonzero__(self):
		"""Always True"""
		return True

	def __len__(self):
		"""The number of containing files"""
		if not self.accessible: raise ranger.fsobject.NotLoadedYet()
		return len(self.files)
	
	def __getitem__(self, key):
		"""Get the file by its index"""
		if not self.accessible: raise ranger.fsobject.NotLoadedYet()
		return self.files[key]

	def __eq__(self, other):
		"""Check for equality of the directories paths"""
		return isinstance(other, Directory) and self.path == other.path

	def __neq__(self, other):
		"""Check for inequality of the directories paths"""
		return not self.__eq__(other)
	
	def __hash__(self):
		return hash(self.path)