fsql icon indicating copy to clipboard operation
fsql copied to clipboard

SELECT query does not print folders from recursive paths.

Open fubarhouse opened this issue 8 years ago • 4 comments

A simple SELECT query should be able to identify the relative path of a file, which should include its folder name.

Example:

fsql "SELECT * from /Users/---/vagrant/jenkins"

prints:

`-rw-r--r--	5248	Dec  7 14:28:14	b874568	config.xml`

instead of:

-rw-r--r--	5248	Dec  7 14:28:14	b874568	jobs/1/config.xml

fubarhouse avatar Dec 11 '17 22:12 fubarhouse

@fubarhouse, thanks for the issue! I agree, relative path definitely makes more sense than just the filename (note that you can get the full path using the FULLPATH attribute modifier).

Kind of limited on time right now, so I'm marking this as help wanted (feel free to give it a go, if you'd like!), but will definitely try to get around to it in the coming weeks.

kashav avatar Dec 12 '17 07:12 kashav

@kshvmdn I've got a one-liner which switches the name out for the path in the walk function.

I've no idea how you want to control this - always on vs optional on, flags etc.

But, for the argument of functionality, I would expect it to always provide the path, rather than the name.

func(path string, info os.FileInfo, result map[string]interface{}) {
	result["name"] = path
	results = append(results, result)

So, this one line makes it do what I would expect it to.

If you'd like this submitted as a PR let me know - but it is one line which might cause a difference in behaviour elsewhere for you.

image

fubarhouse avatar Dec 17 '17 10:12 fubarhouse

@fubarhouse, sorry for the late response – just got the chance to play around with this.

This solution works in the most basic case, but it breaks when using path-modifiers on the name attribute. I'm not sure how to resolve this just yet; I think we're going to have to play around with how names/paths are handled in the format step, maybe use filepath.Rel with the inputted path(s) to get each file's relative path.

Nevertheless, feel free to create the PR, I can merge it to an off-branch and then make changes there. Thanks for taking a look!

kashav avatar Dec 27 '17 00:12 kashav

PR #38 has been created.

fubarhouse avatar Dec 27 '17 10:12 fubarhouse